From 0da0ad399972e7ab522c9d4264afe159855ee7cf Mon Sep 17 00:00:00 2001 From: Jonas Amundsen Date: Tue, 7 Nov 2023 14:18:41 +0100 Subject: [PATCH] Add support for Cypress v10 =< Also drop support for all previous versions. --- .../disable-knapsack-output.feature | 2 +- features/configuration/knapsack.feature | 8 +++---- features/configuration/node.feature | 10 ++++---- features/knapsack.feature | 24 +++++++++---------- features/support/hooks.ts | 20 +++++++++------- .../unweighed-strategies/distribute.feature | 12 +++++----- .../unweighed-strategies/estimate.feature | 12 +++++----- lib/cli.ts | 9 +++++-- package.json | 6 ++--- 9 files changed, 56 insertions(+), 47 deletions(-) diff --git a/features/configuration/disable-knapsack-output.feature b/features/configuration/disable-knapsack-output.feature index 4f98c83..fbe2e7c 100644 --- a/features/configuration/disable-knapsack-output.feature +++ b/features/configuration/disable-knapsack-output.feature @@ -1,7 +1,7 @@ Feature: --disable-knapsack-output Rule: it should disable outputting of the knapsack Background: - Given a file named "cypress/integration/a.js" with: + Given a file named "cypress/e2e/a.js" with: """ it("should pass", () => expect(true).to.be.true); """ diff --git a/features/configuration/knapsack.feature b/features/configuration/knapsack.feature index ee67c75..e4fe30f 100644 --- a/features/configuration/knapsack.feature +++ b/features/configuration/knapsack.feature @@ -1,7 +1,7 @@ Feature: --knapsack Rule: it should store knapsack at provided location (default 'knapsack.json') Background: - Given a file named "cypress/integration/a.js" with: + Given a file named "cypress/e2e/a.js" with: """ it("should pass", () => expect(true).to.be.true); """ @@ -16,7 +16,7 @@ Feature: --knapsack And I should see a file "knapsack.json" with content matching: """ { - "cypress/integration/a.js": \d+ + "cypress/e2e/a.js": \d+ } """ @@ -30,7 +30,7 @@ Feature: --knapsack And I should see a file "sackknap.json" with content matching: """ { - "cypress/integration/a.js": \d+ + "cypress/e2e/a.js": \d+ } """ @@ -44,6 +44,6 @@ Feature: --knapsack And I should see a file "sackknap.json" with content matching: """ { - "cypress/integration/a.js": \d+ + "cypress/e2e/a.js": \d+ } """ diff --git a/features/configuration/node.feature b/features/configuration/node.feature index 2ef3a37..4ab0013 100644 --- a/features/configuration/node.feature +++ b/features/configuration/node.feature @@ -1,23 +1,23 @@ Feature: --node Rule: it should determine bucket of tests Background: - Given a file named "cypress/integration/a.js" with: + Given a file named "cypress/e2e/a.js" with: """ it("should pass", () => expect(true).to.be.true); """ - And a file named "cypress/integration/b.js" with: + And a file named "cypress/e2e/b.js" with: """ it("should pass", () => expect(true).to.be.true); """ - And a file named "cypress/integration/c.js" with: + And a file named "cypress/e2e/c.js" with: """ it("should pass", () => expect(true).to.be.true); """ - And a file named "cypress/integration/d.js" with: + And a file named "cypress/e2e/d.js" with: """ it("should pass", () => expect(true).to.be.true); """ - And a file named "cypress/integration/e.js" with: + And a file named "cypress/e2e/e.js" with: """ it("should pass", () => expect(true).to.be.true); """ diff --git a/features/knapsack.feature b/features/knapsack.feature index 01ddefe..f8bd60c 100644 --- a/features/knapsack.feature +++ b/features/knapsack.feature @@ -1,7 +1,7 @@ Feature: knapsack.json Rule: it should handle any *normal* knapsack scenario somewhat gracefully, otherwise error Scenario: knapsack missing entirely - Given a file named "cypress/integration/a.js" with: + Given a file named "cypress/e2e/a.js" with: """ it("should pass", () => {}); """ @@ -10,7 +10,7 @@ Feature: knapsack.json But it passes Scenario: knapsack missing a file - Given a file named "cypress/integration/a.js" with: + Given a file named "cypress/e2e/a.js" with: """ it("should pass", () => {}); """ @@ -22,15 +22,15 @@ Feature: knapsack.json Then it passes Scenario: knapsack containing a removed file - Given a file named "cypress/integration/a.js" with: + Given a file named "cypress/e2e/a.js" with: """ it("should pass", () => {}); """ And a file named "knapsack.json" with: """ { - "cypress/integration/a.js": 1, - "cypress/integration/b.js": 1 + "cypress/e2e/a.js": 1, + "cypress/e2e/b.js": 1 } """ Given I run cypress-parallel with "--node 1:1" @@ -43,19 +43,19 @@ Feature: knapsack.json "testFiles": "**/a.js" } """ - And a file named "cypress/integration/a.js" with: + And a file named "cypress/e2e/a.js" with: """ it("should pass", () => {}); """ - And a file named "cypress/integration/b.js" with: + And a file named "cypress/e2e/b.js" with: """ it("should pass", () => {}); """ And a file named "knapsack.json" with: """ { - "cypress/integration/a.js": 1, - "cypress/integration/b.js": 1 + "cypress/e2e/a.js": 1, + "cypress/e2e/b.js": 1 } """ Given I run cypress-parallel with "--node 1:1" @@ -63,7 +63,7 @@ Feature: knapsack.json And it should appear as if only a single test ran Scenario: knapsack isn't JSON - Given a file named "cypress/integration/a.js" with: + Given a file named "cypress/e2e/a.js" with: """ it("should pass", () => {}); """ @@ -79,7 +79,7 @@ Feature: knapsack.json """ Scenario: knapsack isn't a valid Record - Given a file named "cypress/integration/a.js" with: + Given a file named "cypress/e2e/a.js" with: """ it("should pass", () => {}); """ @@ -95,7 +95,7 @@ Feature: knapsack.json """ Scenario: knapsack isn't readable - Given a file named "cypress/integration/a.js" with: + Given a file named "cypress/e2e/a.js" with: """ it("should pass", () => {}); """ diff --git a/features/support/hooks.ts b/features/support/hooks.ts index ab9bf80..07cc1b5 100644 --- a/features/support/hooks.ts +++ b/features/support/hooks.ts @@ -21,14 +21,18 @@ Before(async function ({ gherkinDocument, pickle }) { await fs.rm(this.tmpDir, { recursive: true, force: true }); await writeFile( - path.join(this.tmpDir, "cypress.json"), - JSON.stringify( - { - video: false, - }, - null, - 2 - ) + path.join(this.tmpDir, "cypress.config.js"), + ` + const { defineConfig } = require("cypress"); + + module.exports = defineConfig({ + e2e: { + video: false, + supportFile: false, + specPattern: "cypress/e2e/**/*.js", + } + }) + ` ); await fs.mkdir(path.join(this.tmpDir, "node_modules", "@badeball"), { diff --git a/features/unweighed-strategies/distribute.feature b/features/unweighed-strategies/distribute.feature index 2bc0544..952e1e5 100644 --- a/features/unweighed-strategies/distribute.feature +++ b/features/unweighed-strategies/distribute.feature @@ -1,13 +1,13 @@ Feature: distribute (unweighed strategy) Rule: it should distribute unweighed files evenly, despite content length Background: - Given a file named "cypress/integration/a.js" with: + Given a file named "cypress/e2e/a.js" with: """ it("should pass", () => { expect(true).to.be.true }); """ - And a file named "cypress/integration/b.js" with: + And a file named "cypress/e2e/b.js" with: """ it("should pass", () => { expect(true).to.be.true @@ -16,19 +16,19 @@ Feature: distribute (unweighed strategy) expect(true).to.be.true }); """ - And a file named "cypress/integration/c.js" with: + And a file named "cypress/e2e/c.js" with: """ it("should pass", () => expect(true).to.be.true); """ - And a file named "cypress/integration/d.js" with: + And a file named "cypress/e2e/d.js" with: """ it("should pass", () => expect(true).to.be.true); """ And a file named "knapsack.json" with: """ { - "cypress/integration/a.js": 30, - "cypress/integration/b.js": 60 + "cypress/e2e/a.js": 30, + "cypress/e2e/b.js": 60 } """ diff --git a/features/unweighed-strategies/estimate.feature b/features/unweighed-strategies/estimate.feature index 88ecacb..2f6d8cc 100644 --- a/features/unweighed-strategies/estimate.feature +++ b/features/unweighed-strategies/estimate.feature @@ -1,13 +1,13 @@ Feature: estimate (unweighed strategy) Rule: it should distribute unweighed files based off of content length (line numbers) Background: - Given a file named "cypress/integration/a.js" with: + Given a file named "cypress/e2e/a.js" with: """ it("should pass", () => { expect(true).to.be.true }); """ - And a file named "cypress/integration/b.js" with: + And a file named "cypress/e2e/b.js" with: """ it("should pass", () => { expect(true).to.be.true @@ -16,19 +16,19 @@ Feature: estimate (unweighed strategy) expect(true).to.be.true }); """ - And a file named "cypress/integration/c.js" with: + And a file named "cypress/e2e/c.js" with: """ it("should pass", () => expect(true).to.be.true); """ - And a file named "cypress/integration/d.js" with: + And a file named "cypress/e2e/d.js" with: """ it("should pass", () => expect(true).to.be.true); """ And a file named "knapsack.json" with: """ { - "cypress/integration/a.js": 30, - "cypress/integration/b.js": 60 + "cypress/e2e/a.js": 30, + "cypress/e2e/b.js": 60 } """ diff --git a/lib/cli.ts b/lib/cli.ts index 902cd11..18ea93f 100644 --- a/lib/cli.ts +++ b/lib/cli.ts @@ -209,7 +209,12 @@ export async function run(argv: string[], env: NodeJS.ProcessEnv, cwd: string) { disableKnapsackOutput: options.disableKnapsackOutput, }; - const cypressConfiguration = getCypressConfiguration({ argv, env, cwd }); + const cypressConfiguration = getCypressConfiguration({ + testingType: "e2e", + argv, + env, + cwd, + }); const reporterOptions = ["-r", "--reporter", "-o", "--reporter-options"]; @@ -237,7 +242,7 @@ export async function run(argv: string[], env: NodeJS.ProcessEnv, cwd: string) { parallelConfiguration.readKnapsack ?? parallelConfiguration.knapsack ); - const testFiles = getTestFiles({ argv, env, cwd }); + const testFiles = getTestFiles(cypressConfiguration); const weighedFiles: WeighedFile[] = await Object.entries(knapsack).reduce< Promise diff --git a/package.json b/package.json index 2d11609..adacf45 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "prepublishOnly": "npm run clean && npm run build && npm run test" }, "dependencies": { - "@badeball/cypress-configuration": "^1.0.0", + "@badeball/cypress-configuration": "^6.1.0", "commander": "^8.1.0", "cosmiconfig": "^7.0.1", "cypress-multi-reporters": "^1.5.0", @@ -48,7 +48,7 @@ "@types/mocha": "^9.1.0", "@types/shell-quote": "^1.7.1", "@types/stream-buffers": "^3.0.4", - "cypress": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0", + "cypress": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0", "dtslint": "^4.0.5", "esbuild": "^0.11.12", "mocha": "^8.2.0", @@ -59,6 +59,6 @@ "typescript": "^4.0.3" }, "peerDependencies": { - "cypress": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0" + "cypress": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0" } }