diff --git a/cypress.config.js b/cypress.config.js new file mode 100644 index 00000000..6d4fe61e --- /dev/null +++ b/cypress.config.js @@ -0,0 +1,26 @@ +import { defineConfig } from 'cypress'; +import fs from 'fs'; + +export default defineConfig({ + projectId: '2ckppp', + viewportWidth: 1440, + viewportHeight: 768, + snapshotFileName: './cypress/snapshots.js', + defaultCommandTimeout: 16000, + requestTimeout: 16000, + e2e: { + setupNodeEvents(on, config) { + on('task', { + readFileMaybe(filename) { + if (fs.existsSync(filename)) { + return fs.readFileSync(filename, 'utf8'); + } + + return null; + } + }); + }, + baseUrl: 'http://localhost:3000', + specPattern: 'cypress/e2e/**/*.{js,jsx,ts,tsx}' + } +}); diff --git a/cypress.json b/cypress.json deleted file mode 100644 index 70b8e6bd..00000000 --- a/cypress.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "projectId": "2ckppp", - "$schema": "https://on.cypress.io/cypress.schema.json", - "baseUrl": "http://localhost:3000", - "pluginsFile": "./cypress/plugins/index.cjs", - "viewportWidth": 1440, - "viewportHeight": 768, - "snapshotFileName": "./cypress/snapshots.js", - "defaultCommandTimeout": 16000, - "requestTimeout": 16000 -} diff --git a/cypress/integration/actions.spec.ts b/cypress/e2e/actions.spec.ts similarity index 100% rename from cypress/integration/actions.spec.ts rename to cypress/e2e/actions.spec.ts diff --git a/cypress/integration/diagramUpdate.spec.ts b/cypress/e2e/diagramUpdate.spec.ts similarity index 100% rename from cypress/integration/diagramUpdate.spec.ts rename to cypress/e2e/diagramUpdate.spec.ts diff --git a/cypress/integration/docMap.spec.ts b/cypress/e2e/docMap.spec.ts similarity index 100% rename from cypress/integration/docMap.spec.ts rename to cypress/e2e/docMap.spec.ts diff --git a/cypress/integration/history.spec.ts b/cypress/e2e/history.spec.ts similarity index 100% rename from cypress/integration/history.spec.ts rename to cypress/e2e/history.spec.ts diff --git a/cypress/integration/loadSite.spec.ts b/cypress/e2e/loadSite.spec.ts similarity index 100% rename from cypress/integration/loadSite.spec.ts rename to cypress/e2e/loadSite.spec.ts diff --git a/cypress/integration/themes.spec.ts b/cypress/e2e/themes.spec.ts similarity index 100% rename from cypress/integration/themes.spec.ts rename to cypress/e2e/themes.spec.ts diff --git a/cypress/plugins/index.cjs b/cypress/plugins/index.cjs deleted file mode 100644 index f7ffbe14..00000000 --- a/cypress/plugins/index.cjs +++ /dev/null @@ -1,31 +0,0 @@ -/// -// *********************************************************** -// This example plugins/index.js can be used to load plugins -// -// You can change the location of this file or turn off loading -// the plugins file with the 'pluginsFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/plugins-guide -// *********************************************************** - -// This function is called when a project is opened or re-opened (e.g. due to -// the project's config changing) - -/** - * @type {Cypress.PluginConfig} - */ -// eslint-disable-next-line no-unused-vars -import * as fs from 'fs'; - -module.exports = (on, config) => { - on('task', { - readFileMaybe(filename) { - if (fs.existsSync(filename)) { - return fs.readFileSync(filename, 'utf8'); - } - - return null; - } - }); -}; diff --git a/cypress/snapshots.js b/cypress/snapshots.js index 1712b1c4..f351ae4d 100644 --- a/cypress/snapshots.js +++ b/cypress/snapshots.js @@ -16,7 +16,7 @@ module.exports = { "1": "{\"code\":\"graph TD\\n A[Party] -->|Get money| B(Go shopping!!)\\n \",\"mermaid\":\"{\\n \\\"theme\\\": \\\"forest\\\",\\n \\\"test\\\": \\\"hello world\\\"\\n}\",\"updateEditor\":false,\"autoSync\":true,\"updateDiagram\":true,\"loader\":{\"type\":\"files\",\"config\":{\"codeURL\":\"https://gist.githubusercontent.com/sidharthv96/6268a23e673a533dcb198f241fd7012a/raw/4eb03887e6a41397e80bdcdbf94017c498f8f1e2/code.mmd\",\"configURL\":\"https://gist.githubusercontent.com/sidharthv96/6268a23e673a533dcb198f241fd7012a/raw/4eb03887e6a41397e80bdcdbf94017c498f8f1e2/config.json\"}}}" } }, - "__version": "9.7.0", + "__version": "10.0.3", "Auto sync tests": { "should dim diagram when code is edited": { "1": "{\"code\":\"graph TD\\n A[Christmas] -->|Get money| B(Go shopping)\\n B --> C{Let me think}\\n C -->|One| D[Laptop]\\n C -->|Two| E[iPhone]\\n C -->|Three| F[fa:fa-car Car]\\n C --> Test\",\"mermaid\":\"{\\n \\\"theme\\\": \\\"default\\\"\\n}\",\"updateEditor\":false,\"autoSync\":false,\"updateDiagram\":false}" diff --git a/cypress/support/index.js b/cypress/support/e2e.js similarity index 100% rename from cypress/support/index.js rename to cypress/support/e2e.js diff --git a/package.json b/package.json index eb7f5c10..30af1d7e 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "lint:fix": "prettier --write --plugin-search-dir=. .;eslint --fix --ignore-path .gitignore .", "format": "prettier --write --plugin-search-dir=. .", "pre-commit": "lint-staged", - "postinstall": "husky install", + "postinstall": "husky install; cypress cache prune", "test": "cypress run", "cy": "cypress open" }, @@ -24,7 +24,7 @@ "autoprefixer": "^10.4.7", "chai": "^4.3.6", "cssnano": "^5.1.9", - "cypress": "9.7.0", + "cypress": "10.0.3", "cypress-localstorage-commands": "^2.1.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.5.0", diff --git a/snapshots.js b/snapshots.js deleted file mode 100644 index e69de29b..00000000 diff --git a/tsconfig.json b/tsconfig.json index af0b0794..92fe9a28 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,8 @@ "src/**/*.svelte", "cypress/**/*.ts", "cypress/**/*.js", - "static/**/*.js" + "static/**/*.js", + "cypress.config.ts" ], "extends": "./.svelte-kit/tsconfig.json" } diff --git a/yarn.lock b/yarn.lock index aecb4fa1..231da150 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1071,10 +1071,10 @@ cypress-localstorage-commands@^2.1.0: resolved "https://registry.yarnpkg.com/cypress-localstorage-commands/-/cypress-localstorage-commands-2.1.0.tgz#6fc299ec60b6b5ccfc09dd23d004866b7444ee78" integrity sha512-DIJLCIh+CcKulAxMVEng6EhpW691emHRqFUD4dK2HUn86Xzt3ABL3SkmxW4rXgvQt697nTDpZC+jo5K5BwndrQ== -cypress@9.7.0: - version "9.7.0" - resolved "https://registry.yarnpkg.com/cypress/-/cypress-9.7.0.tgz#bf55b2afd481f7a113ef5604aa8b693564b5e744" - integrity sha512-+1EE1nuuuwIt/N1KXRR2iWHU+OiIt7H28jJDyyI4tiUftId/DrXYEwoDa5+kH2pki1zxnA0r6HrUGHV5eLbF5Q== +cypress@10.0.3: + version "10.0.3" + resolved "https://registry.yarnpkg.com/cypress/-/cypress-10.0.3.tgz#889b4bef863b7d1ef1b608b85b964394ad350c5f" + integrity sha512-8C82XTybsEmJC9POYSNITGUhMLCRwB9LadP0x33H+52QVoBjhsWvIzrI+ybCe0+TyxaF0D5/9IL2kSTgjqCB9A== dependencies: "@cypress/request" "^2.88.10" "@cypress/xvfb" "^1.2.4"