diff --git a/cypress.config.js b/cypress.config.ts similarity index 81% rename from cypress.config.js rename to cypress.config.ts index 0201e6e..f1bc680 100644 --- a/cypress.config.js +++ b/cypress.config.ts @@ -13,6 +13,11 @@ export default defineConfig({ devServer: { framework: "react", bundler: "vite", + viteConfig: { + server: { + port: 5174, + }, + }, }, }, }); diff --git a/cypress/e2e/app.cy.ts b/cypress/e2e/app.cy.ts deleted file mode 100644 index 65e00d0..0000000 --- a/cypress/e2e/app.cy.ts +++ /dev/null @@ -1,5 +0,0 @@ -describe("template spec", () => { - it("passes", () => { - cy.visit("/"); - }); -}); diff --git a/cypress/support/commands.js b/cypress/support/commands.js deleted file mode 100644 index 66ea16e..0000000 --- a/cypress/support/commands.js +++ /dev/null @@ -1,25 +0,0 @@ -// *********************************************** -// This example commands.js shows you how to -// create various custom commands and overwrite -// existing commands. -// -// For more comprehensive examples of custom -// commands please read more here: -// https://on.cypress.io/custom-commands -// *********************************************** -// -// -// -- This is a parent command -- -// Cypress.Commands.add('login', (email, password) => { ... }) -// -// -// -- This is a child command -- -// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) -// -// -// -- This is a dual command -- -// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) -// -// -// -- This will overwrite an existing command -- -// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) \ No newline at end of file diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 698b01a..177a868 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -34,4 +34,33 @@ // visit(originalFn: CommandOriginalFn, url: string, options: Partial): Chainable // } // } -// } \ No newline at end of file +// } + +Cypress.Commands.add("dataCy", (value: string) => { + return cy.get(`[data-cy="${value}"]`); +}); + +Cypress.Commands.add("disableTransitions", () => { + cy.document().then((document) => { + const style = document.createElement("style"); + style.id = "cypress-disable-transitions"; + style.innerHTML = ` + * { + transition: none !important; + animation: none !important; + animation-duration: 0ms !important; + transition-duration: 0ms !important; + } + `; + document.head.appendChild(style); + }); +}); + +Cypress.Commands.add("enableTransitions", () => { + cy.document().then((document) => { + const styleElement = document.getElementById("cypress-disable-transitions"); + if (styleElement) { + styleElement.remove(); + } + }); +}); diff --git a/cypress/support/component.js b/cypress/support/component.js deleted file mode 100644 index 6700fb3..0000000 --- a/cypress/support/component.js +++ /dev/null @@ -1,24 +0,0 @@ -// *********************************************************** -// This example support/component.js is processed and -// loaded automatically before your test files. -// -// This is a great place to put global configuration and -// behavior that modifies Cypress. -// -// You can change the location of this file or turn off -// automatically serving support files with the -// 'supportFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/configuration -// *********************************************************** - -// Import commands.js using ES2015 syntax: -import './commands' - -import { mount } from 'cypress/react' - -Cypress.Commands.add('mount', mount) - -// Example use: -// cy.mount() \ No newline at end of file diff --git a/cypress/support/component.ts b/cypress/support/component.ts new file mode 100644 index 0000000..fac7de6 --- /dev/null +++ b/cypress/support/component.ts @@ -0,0 +1,39 @@ +// *********************************************************** +// This example support/component.ts is processed and +// loaded automatically before your test files. +// +// This is a great place to put global configuration and +// behavior that modifies Cypress. +// +// You can change the location of this file or turn off +// automatically serving support files with the +// 'supportFile' configuration option. +// +// You can read more here: +// https://on.cypress.io/configuration +// *********************************************************** + +// Import commands.js using ES2015 syntax: +import "./commands"; + +import { mount } from "cypress/react"; + +// Augment the Cypress namespace to include type definitions for +// your custom command. +// Alternatively, can be defined in cypress/support/component.d.ts +// with a at the top of your spec. +declare global { + namespace Cypress { + interface Chainable { + mount: typeof mount; + dataCy(value: string): Chainable>; + disableTransitions(): Chainable; + enableTransitions(): Chainable; + } + } +} + +Cypress.Commands.add("mount", mount); + +// Example use: +// cy.mount() diff --git a/package.json b/package.json index 1360aad..050a6b7 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,6 @@ "name": "luminance", "private": true, "version": "0.0.0", - "type": "module", "scripts": { "build": "tsc -b && vite build", "build:wasm": "wasm-pack build colorlib -t bundler -d pkg --release", diff --git a/tsconfig.cypress.json b/tsconfig.cypress.json index cc3d800..f38618e 100644 --- a/tsconfig.cypress.json +++ b/tsconfig.cypress.json @@ -1,10 +1,13 @@ { "compilerOptions": { "target": "es5", + "module": "commonjs", + "moduleResolution": "node", "lib": ["es5", "dom"], + "jsx": "react-jsx", "types": ["cypress", "node"], - "module": "CommonJS", - "moduleResolution": "node" + "sourceMap": true, + "preserveValueImports": false }, - "include": ["cypress/**/*.ts", "cypress/**/*.tsx"] + "include": ["**/*.ts", "**/*.tsx"] } diff --git a/tsconfig.json b/tsconfig.json index a2011ee..bf50381 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "files": [], "references": [ { "path": "./tsconfig.app.json" }, - { "path": "./tsconfig.node.json" } + { "path": "./tsconfig.node.json" }, { "path": "./tsconfig.cypress.json" } ] } diff --git a/vite.config.ts b/vite.config.ts index 1c0713a..90c0136 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -11,4 +11,7 @@ export default defineConfig({ wasm(), topLevelAwait(), ], + server: { + port: 5173, + } })