From 398312e889f9ac4f05f8ebb64b7c2fcec0f7e80c Mon Sep 17 00:00:00 2001 From: Douglas Wade Date: Tue, 5 Dec 2023 16:07:26 -0800 Subject: [PATCH] fix(#170): fix cypress tests --- .eslintrc.js | 6 +++++ package.json | 2 +- packages/cypress/e2e/website/guides.cy.js | 22 ++++++++++++++++ packages/cypress/e2e/website/index.cy.js | 10 ------- packages/cypress/e2e/website/lighthouse.cy.js | 0 packages/cypress/e2e/website/packages.cy.js | 26 +++++++++++++++++++ packages/cypress/e2e/website/pages.cy.js | 25 ------------------ packages/cypress/package.json | 1 + 8 files changed, 56 insertions(+), 36 deletions(-) create mode 100644 packages/cypress/e2e/website/guides.cy.js create mode 100644 packages/cypress/e2e/website/lighthouse.cy.js create mode 100644 packages/cypress/e2e/website/packages.cy.js delete mode 100644 packages/cypress/e2e/website/pages.cy.js diff --git a/.eslintrc.js b/.eslintrc.js index 32e04e87..4669da3a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -6,4 +6,10 @@ module.exports = { rules: { '@typescript-eslint/no-explicit-any': 'off', }, + overrides:[ + { + files: ['*.cy.js'], + extends: ['plugin:cypress/recommended'], + }, + ], }; diff --git a/package.json b/package.json index 340c4214..2de06a9f 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "format": "prettier --write .", "generate-scaffold": "cd ./packages/cli/out && yarn run exec-source scaffold eleventy --name my-example && cd ../../..", "generate-types": "turbo generate-types", - "lint": "eslint packages/**!(node_modules)/src/**/*.ts", + "lint": "eslint packages/**!(node_modules)/src/**/*.ts packages/cypress/e2e/**/*.js packages/cypress/support/*.js", "serve": "turbo run serve --parallel", "test": "turbo test", "watch": "turbo run watch --parallel" diff --git a/packages/cypress/e2e/website/guides.cy.js b/packages/cypress/e2e/website/guides.cy.js new file mode 100644 index 00000000..d9a2b6aa --- /dev/null +++ b/packages/cypress/e2e/website/guides.cy.js @@ -0,0 +1,22 @@ +/// + +const guides = [ + 'custom-validator', + 'new-website', + 'styling-your-component', + 'writing-tests' +]; + +guides.forEach((guide) => { + describe(`guide: ${guide}`, () => { + beforeEach(() => { + cy.visit(`http://localhost:8081/pages/${guide}-guide/`); + }); + + it('should mount the layout', () => { + cy.get('tybalt-header').should('have.length', 1); + cy.get('tybalt-sidebar').should('have.length', 1); + cy.get('tybalt-footer').should('have.length', 1); + }); + }); +}); \ No newline at end of file diff --git a/packages/cypress/e2e/website/index.cy.js b/packages/cypress/e2e/website/index.cy.js index f8745f90..1ca49c0a 100644 --- a/packages/cypress/e2e/website/index.cy.js +++ b/packages/cypress/e2e/website/index.cy.js @@ -13,14 +13,4 @@ describe('index.html', () => { cy.get('tybalt-sidebar').should('have.length', 1); cy.get('tybalt-footer').should('have.length', 1); }); - - it('pass the lighthouse audit', () => { - cy.lighthouse({ - accessibility: 90, - 'best-practices': 90, - seo: 90, - pwa: 90, - performance: 90, - }); - }); }); diff --git a/packages/cypress/e2e/website/lighthouse.cy.js b/packages/cypress/e2e/website/lighthouse.cy.js new file mode 100644 index 00000000..e69de29b diff --git a/packages/cypress/e2e/website/packages.cy.js b/packages/cypress/e2e/website/packages.cy.js new file mode 100644 index 00000000..0a59addc --- /dev/null +++ b/packages/cypress/e2e/website/packages.cy.js @@ -0,0 +1,26 @@ +/// + +const packages = [ + 'cli', + 'core', + 'eleventy-plugin', + 'esbuild-plugin', + 'eslint-plugin', + 'parser', + 'test-utils', + 'validator' +]; + +packages.forEach((pkg) => { + describe(`package: ${pkg}`, () => { + beforeEach(() => { + cy.visit(`http://localhost:8081/pages/${pkg}/`); + }); + + it('should mount the layout', () => { + cy.get('tybalt-header').should('have.length', 1); + cy.get('tybalt-sidebar').should('have.length', 1); + cy.get('tybalt-footer').should('have.length', 1); + }); + }); +}); \ No newline at end of file diff --git a/packages/cypress/e2e/website/pages.cy.js b/packages/cypress/e2e/website/pages.cy.js deleted file mode 100644 index 01d1888a..00000000 --- a/packages/cypress/e2e/website/pages.cy.js +++ /dev/null @@ -1,25 +0,0 @@ -/// - -const baseUrl = 'http://localhost:8081/pages/core/'; - -describe('markdown pages', () => { - beforeEach(() => { - cy.visit(baseUrl); - }); - - it('should mount the layout', () => { - cy.get('tybalt-header').should('have.length', 1); - cy.get('tybalt-sidebar').should('have.length', 1); - cy.get('tybalt-footer').should('have.length', 1); - }); - - it('should pass the lighthouse audit', () => { - cy.lighthouse({ - accessibility: 90, - 'best-practices': 90, - seo: 90, - pwa: 90, - performance: 90, - }); - }); -}); diff --git a/packages/cypress/package.json b/packages/cypress/package.json index c057f78c..5d489d6f 100644 --- a/packages/cypress/package.json +++ b/packages/cypress/package.json @@ -6,6 +6,7 @@ "scripts": { "build": "yarn run compile && yarn run generate-types", "clean": "rimraf dist/", + "lint": "eslint ese/ src/ support/", "compile": "esbuild src/index.ts --format=cjs --outdir=dist", "generate-types": "tsc" },