-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(test): migrate Cypress to version 10
release-npm BREAKING CHANGE: if added optional dependency Cypress requires at least version 10
- Loading branch information
Showing
9 changed files
with
146 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { existsSync } from 'fs' | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { defineConfig } from 'cypress' | ||
import objectAssignDeep from 'object-assign-deep' | ||
// eslint-disable-next-line import/no-unresolved | ||
import packageJson from '../../../package.json' assert { type: 'json' } | ||
import { log } from '../utility/helper.js' | ||
|
||
const importFileContents = async (fileName, readableName) => { | ||
let result = {} | ||
const filePath = `./../../../${fileName}` | ||
|
||
if (existsSync(filePath)) { | ||
try { | ||
result = await import(filePath) | ||
} catch (error) { | ||
console.log(error) | ||
log(`Failed to read ${readableName} from ${filePath}.`, 'warning') | ||
} | ||
} | ||
|
||
// Normalize CJS and ESM. | ||
if (typeof result === 'object' && typeof result.default !== 'undefined') { | ||
result = result.default | ||
} | ||
|
||
return result | ||
} | ||
|
||
const userConfig = await importFileContents('cypress.config.js', 'user cypress config') | ||
const plugin = await importFileContents( | ||
'cypress/plugins/index.cjs', | ||
'package cypress configuration' | ||
) | ||
|
||
let packageJsonConfig = {} | ||
|
||
if (packageJson.papua && typeof packageJson.papua.cypress === 'object') { | ||
packageJsonConfig = packageJson.papua.cypress | ||
} | ||
|
||
const defaults = { | ||
chromeWebSecurity: false, | ||
e2e: { | ||
// We've imported your old cypress plugins here. | ||
// You may want to clean this up later by importing these. | ||
setupNodeEvents(on, config) { | ||
console.log('setup', plugin) | ||
return plugin && plugin(on, config) | ||
}, | ||
}, | ||
} | ||
|
||
const result = objectAssignDeep(defaults, packageJsonConfig, userConfig) | ||
|
||
export default defineConfig(result) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.