Skip to content

Commit

Permalink
Add support for Cypress v10 =<
Browse files Browse the repository at this point in the history
Also drop support for all previous versions.
  • Loading branch information
badeball committed Nov 7, 2023
1 parent 0d92169 commit 0da0ad3
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 47 deletions.
2 changes: 1 addition & 1 deletion features/configuration/disable-knapsack-output.feature
Original file line number Diff line number Diff line change
@@ -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);
"""
Expand Down
8 changes: 4 additions & 4 deletions features/configuration/knapsack.feature
Original file line number Diff line number Diff line change
@@ -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);
"""
Expand All @@ -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+
}
"""

Expand All @@ -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+
}
"""

Expand All @@ -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+
}
"""
10 changes: 5 additions & 5 deletions features/configuration/node.feature
Original file line number Diff line number Diff line change
@@ -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);
"""
Expand Down
24 changes: 12 additions & 12 deletions features/knapsack.feature
Original file line number Diff line number Diff line change
@@ -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", () => {});
"""
Expand All @@ -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", () => {});
"""
Expand All @@ -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"
Expand All @@ -43,27 +43,27 @@ 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"
Then it passes
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", () => {});
"""
Expand All @@ -79,7 +79,7 @@ Feature: knapsack.json
"""

Scenario: knapsack isn't a valid Record<string, number>
Given a file named "cypress/integration/a.js" with:
Given a file named "cypress/e2e/a.js" with:
"""
it("should pass", () => {});
"""
Expand All @@ -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", () => {});
"""
Expand Down
20 changes: 12 additions & 8 deletions features/support/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"), {
Expand Down
12 changes: 6 additions & 6 deletions features/unweighed-strategies/distribute.feature
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
}
"""

Expand Down
12 changes: 6 additions & 6 deletions features/unweighed-strategies/estimate.feature
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
}
"""

Expand Down
9 changes: 7 additions & 2 deletions lib/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"];

Expand Down Expand Up @@ -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<WeighedFile[]>
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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"
}
}

0 comments on commit 0da0ad3

Please sign in to comment.