Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"timings": "DEBUG=cypress-split SPLIT=2 SPLIT_INDEX=0 SPLIT_FILE=timings.json cypress run",
"timings-no-file": "DEBUG=cypress-split SPLIT=1 SPLIT_INDEX=0 SPLIT_FILE=does-not-exist.json cypress run",
"timings-split-output-file": "DEBUG=cypress-split SPLIT=2 SPLIT_INDEX=0 SPLIT_OUTPUT_FILE=new-timings.json SPLIT_FILE=timings.json cypress run",
"timings-alternative-config": "SPLIT=2 SPLIT_INDEX=0 SPLIT_FILE=alternative-config-timings.json cypress run --config-file test/alternative-cypress.config.js",
"demo-merge": "node ./bin/merge --parent-folder examples/split-times --split-file timings.json --output out-timings.json",
"demo-preview": "node ./bin/preview --split 2",
"demo-preview-spec": "SPEC=\"cypress/e2e/spec*.cy.js\" node ./bin/preview --split 2",
Expand Down
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ function cypressSplit(on, config) {

const specDurations = splitSpecs
.map((absoluteSpecPath, k) => {
const relativeName = specAbsoluteToRelative[absoluteSpecPath]
const cwd = process.cwd()
const useFix = !!process.env['SPLIT_FIX']
const relativeName = useFix
? path.relative(cwd, absoluteSpecPath)
: specAbsoluteToRelative[absoluteSpecPath]
const specResult = specResults[absoluteSpecPath]
if (specResult) {
const passed = hasSpecPassed(specResult)
Expand Down
7 changes: 4 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ function splitSpecsLogic({ specs, splitN, splitIndex, splitFileName, label }) {
previousDurations.length
const specsWithDurations = specs.map((specName) => {
const relativeSpec = path.relative(cwd, specName)
const foundInfo = previousDurations.find(
(item) => item.spec === relativeSpec,
)
const foundInfo = previousDurations.find((item) => {
console.log(`Comparing ${item.spec} with ${relativeSpec}`)
return item.spec === relativeSpec
})
if (!foundInfo) {
return {
specName,
Expand Down
29 changes: 29 additions & 0 deletions test/alternative-cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const { defineConfig } = require('cypress')
const cypressSplit = require('../src')

module.exports = defineConfig({
e2e: {
// baseUrl, etc
supportFile: false,
fixturesFolder: false,
excludeSpecPattern: '*.hot-update.js',
setupNodeEvents(on, config) {
cypressSplit(on, config)
// IMPORTANT: return the config object
return config
},
},

component: {
devServer: {
framework: 'react',
bundler: 'vite',
},
specPattern: 'components/*.cy.js',
setupNodeEvents(on, config) {
cypressSplit(on, config)
// IMPORTANT: return the config object
return config
},
},
})