-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(testing): update cypress version (#21961)
- Loading branch information
1 parent
776367e
commit dd2c7d2
Showing
4 changed files
with
65 additions
and
1 deletion.
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
42 changes: 42 additions & 0 deletions
42
packages/cypress/src/migrations/update-18-1-0/update-cypress-version-13-6-6.spec.ts
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,42 @@ | ||
import { readJson, updateJson, type Tree } from '@nx/devkit'; | ||
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; | ||
import * as cypressVersionUtils from '../../utils/cypress-version'; | ||
import migration from './update-cypress-version-13-6-6'; | ||
|
||
describe('update-cypress-version migration', () => { | ||
let tree: Tree; | ||
|
||
function setCypressVersion(version: string) { | ||
updateJson(tree, 'package.json', (json) => { | ||
json.devDependencies ??= {}; | ||
json.devDependencies.cypress = version; | ||
return json; | ||
}); | ||
const major = parseInt(version.split('.')[0].replace('^', ''), 10); | ||
jest | ||
.spyOn(cypressVersionUtils, 'installedCypressVersion') | ||
.mockReturnValue(major); | ||
} | ||
|
||
beforeEach(() => { | ||
tree = createTreeWithEmptyWorkspace(); | ||
}); | ||
|
||
it('should bump cypress version to ^13.6.6', async () => { | ||
setCypressVersion('^13.0.0'); | ||
|
||
await migration(tree); | ||
|
||
const { devDependencies } = readJson(tree, 'package.json'); | ||
expect(devDependencies.cypress).toBe('^13.6.6'); | ||
}); | ||
|
||
it('should not update cypress version if it is not >= 13', async () => { | ||
setCypressVersion('^12.0.0'); | ||
|
||
await migration(tree); | ||
|
||
const { devDependencies } = readJson(tree, 'package.json'); | ||
expect(devDependencies.cypress).toBe('^12.0.0'); | ||
}); | ||
}); |
16 changes: 16 additions & 0 deletions
16
packages/cypress/src/migrations/update-18-1-0/update-cypress-version-13-6-6.ts
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,16 @@ | ||
import { | ||
addDependenciesToPackageJson, | ||
formatFiles, | ||
type Tree, | ||
} from '@nx/devkit'; | ||
import { installedCypressVersion } from '../../utils/cypress-version'; | ||
|
||
export default async function (tree: Tree) { | ||
if (installedCypressVersion() < 13) { | ||
return; | ||
} | ||
|
||
addDependenciesToPackageJson(tree, {}, { cypress: '^13.6.6' }); | ||
|
||
await formatFiles(tree); | ||
} |
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