diff --git a/packages/workspace/src/generators/move/lib/update-cypress-config.spec.ts b/packages/workspace/src/generators/move/lib/update-cypress-config.spec.ts index c0793b9237..fe66d7f0a9 100644 --- a/packages/workspace/src/generators/move/lib/update-cypress-config.spec.ts +++ b/packages/workspace/src/generators/move/lib/update-cypress-config.spec.ts @@ -59,6 +59,25 @@ describe('updateCypressConfig', () => { }); }); + it('should noop if the videos and screenshots folders are not defined', async () => { + const cypressJson = { + fileServerFolder: '.', + fixturesFolder: './src/fixtures', + integrationFolder: './src/integration', + pluginsFile: './src/plugins/index', + supportFile: false, + video: false, + chromeWebSecurity: false, + }; + writeJson(tree, '/libs/my-destination/cypress.json', cypressJson); + + updateCypressConfig(tree, schema, projectConfig); + + expect(readJson(tree, '/libs/my-destination/cypress.json')).toEqual( + cypressJson + ); + }); + it('should handle updating cypress.config.ts', async () => { tree.write( '/libs/my-destination/cypress.config.ts', diff --git a/packages/workspace/src/generators/move/lib/update-cypress-config.ts b/packages/workspace/src/generators/move/lib/update-cypress-config.ts index e726aaf748..67670b5121 100644 --- a/packages/workspace/src/generators/move/lib/update-cypress-config.ts +++ b/packages/workspace/src/generators/move/lib/update-cypress-config.ts @@ -28,14 +28,20 @@ export function updateCypressConfig( const cypressJson = JSON.parse( tree.read(cypressJsonPath).toString('utf-8') ) as PartialCypressJson; - cypressJson.videosFolder = cypressJson.videosFolder.replace( - project.root, - schema.relativeToRootDestination - ); - cypressJson.screenshotsFolder = cypressJson.screenshotsFolder.replace( - project.root, - schema.relativeToRootDestination - ); + // videosFolder is not required because videos can be turned off - it also has a default + if (cypressJson.videosFolder) { + cypressJson.videosFolder = cypressJson.videosFolder.replace( + project.root, + schema.relativeToRootDestination + ); + } + // screenshotsFolder is not required as it has a default + if (cypressJson.screenshotsFolder) { + cypressJson.screenshotsFolder = cypressJson.screenshotsFolder.replace( + project.root, + schema.relativeToRootDestination + ); + } tree.write(cypressJsonPath, JSON.stringify(cypressJson)); return tree;