cleanup(testing): switch cypress tests to use project name and root as-provided format by default (#18927)

This commit is contained in:
Leosvel Pérez Espinosa 2023-08-31 15:00:50 +01:00 committed by GitHub
parent 1abe35c52b
commit a2493b92f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 252 additions and 230 deletions

View File

@ -4,7 +4,7 @@ exports[`Cypress Project < v7 --linter eslint should add eslint-plugin-cypress 1
{
"extends": [
"plugin:cypress/recommended",
"../../.eslintrc.json",
"../.eslintrc.json",
],
"ignorePatterns": [
"!**/*",
@ -42,17 +42,17 @@ exports[`Cypress Project < v7 nested should update configuration 1`] = `
},
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/my-dir/my-app-e2e/cypress.json",
"cypressConfig": "my-dir/my-app-e2e/cypress.json",
"devServerTarget": "my-dir-my-app:serve",
"testingType": "e2e",
"tsConfig": "apps/my-dir/my-app-e2e/tsconfig.json",
"tsConfig": "my-dir/my-app-e2e/tsconfig.json",
},
},
"lint": {
"executor": "@nx/linter:eslint",
"options": {
"lintFilePatterns": [
"apps/my-dir/my-app-e2e/**/*.{js,ts}",
"my-dir/my-app-e2e/**/*.{js,ts}",
],
},
"outputs": [
@ -71,8 +71,8 @@ exports[`Cypress Project < v7 project with directory in its name should set righ
"supportFile": "./src/support/index.ts",
"pluginsFile": "./src/plugins/index",
"video": true,
"videosFolder": "../../../dist/cypress/apps/my-dir/my-app-e2e/videos",
"screenshotsFolder": "../../../dist/cypress/apps/my-dir/my-app-e2e/screenshots",
"videosFolder": "../../dist/cypress/my-dir/my-app-e2e/videos",
"screenshotsFolder": "../../dist/cypress/my-dir/my-app-e2e/screenshots",
"chromeWebSecurity": false
}
"
@ -88,17 +88,17 @@ exports[`Cypress Project < v7 project with directory in its name should update c
},
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/my-dir/my-app-e2e/cypress.json",
"cypressConfig": "my-dir/my-app-e2e/cypress.json",
"devServerTarget": "my-dir-my-app:serve",
"testingType": "e2e",
"tsConfig": "apps/my-dir/my-app-e2e/tsconfig.json",
"tsConfig": "my-dir/my-app-e2e/tsconfig.json",
},
},
"lint": {
"executor": "@nx/linter:eslint",
"options": {
"lintFilePatterns": [
"apps/my-dir/my-app-e2e/**/*.{js,ts}",
"my-dir/my-app-e2e/**/*.{js,ts}",
],
},
"outputs": [
@ -108,22 +108,22 @@ exports[`Cypress Project < v7 project with directory in its name should update c
}
`;
exports[`Cypress Project < v7 should update configuration (baseUrl) 1`] = `
exports[`Cypress Project < v7 should update project configuration (baseUrl) 1`] = `
{
"e2e": {
"executor": "@nx/cypress:cypress",
"options": {
"baseUrl": "http://localhost:3000",
"cypressConfig": "apps/my-app-e2e/cypress.json",
"cypressConfig": "my-app-e2e/cypress.json",
"testingType": "e2e",
"tsConfig": "apps/my-app-e2e/tsconfig.json",
"tsConfig": "my-app-e2e/tsconfig.json",
},
},
"lint": {
"executor": "@nx/linter:eslint",
"options": {
"lintFilePatterns": [
"apps/my-app-e2e/**/*.{js,ts}",
"my-app-e2e/**/*.{js,ts}",
],
},
"outputs": [
@ -133,7 +133,7 @@ exports[`Cypress Project < v7 should update configuration (baseUrl) 1`] = `
}
`;
exports[`Cypress Project < v7 should update configuration 1`] = `
exports[`Cypress Project < v7 should update project configuration 1`] = `
{
"e2e": {
"configurations": {
@ -143,17 +143,17 @@ exports[`Cypress Project < v7 should update configuration 1`] = `
},
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/my-app-e2e/cypress.json",
"cypressConfig": "my-app-e2e/cypress.json",
"devServerTarget": "my-app:serve",
"testingType": "e2e",
"tsConfig": "apps/my-app-e2e/tsconfig.json",
"tsConfig": "my-app-e2e/tsconfig.json",
},
},
"lint": {
"executor": "@nx/linter:eslint",
"options": {
"lintFilePatterns": [
"apps/my-app-e2e/**/*.{js,ts}",
"my-app-e2e/**/*.{js,ts}",
],
},
"outputs": [
@ -163,7 +163,7 @@ exports[`Cypress Project < v7 should update configuration 1`] = `
}
`;
exports[`Cypress Project < v7 should update configuration 2`] = `
exports[`Cypress Project < v7 should update target configurations 1`] = `
{
"e2e": {
"configurations": {
@ -173,17 +173,17 @@ exports[`Cypress Project < v7 should update configuration 2`] = `
},
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/my-app-e2e/cypress.json",
"cypressConfig": "my-app-e2e/cypress.json",
"devServerTarget": "my-app:serve:development",
"testingType": "e2e",
"tsConfig": "apps/my-app-e2e/tsconfig.json",
"tsConfig": "my-app-e2e/tsconfig.json",
},
},
"lint": {
"executor": "@nx/linter:eslint",
"options": {
"lintFilePatterns": [
"apps/my-app-e2e/**/*.{js,ts}",
"my-app-e2e/**/*.{js,ts}",
],
},
"outputs": [
@ -219,14 +219,14 @@ exports[`Cypress Project > v10 nested should set right path names in \`tsconfig.
{
"compilerOptions": {
"allowJs": true,
"outDir": "../../../dist/out-tsc",
"outDir": "../../dist/out-tsc",
"sourceMap": false,
"types": [
"cypress",
"node",
],
},
"extends": "../../../tsconfig.base.json",
"extends": "../../tsconfig.base.json",
"include": [
"src/**/*.ts",
"src/**/*.js",
@ -249,14 +249,14 @@ exports[`Cypress Project > v10 should set right path names in \`tsconfig.e2e.jso
{
"compilerOptions": {
"allowJs": true,
"outDir": "../../dist/out-tsc",
"outDir": "../dist/out-tsc",
"sourceMap": false,
"types": [
"cypress",
"node",
],
},
"extends": "../../tsconfig.base.json",
"extends": "../tsconfig.base.json",
"include": [
"src/**/*.ts",
"src/**/*.js",
@ -270,7 +270,7 @@ exports[`Cypress Project > v10 should update configuration when eslint is passed
"executor": "@nx/linter:eslint",
"options": {
"lintFilePatterns": [
"apps/my-app-e2e/**/*.{js,ts}",
"my-app-e2e/**/*.{js,ts}",
],
},
"outputs": [

View File

@ -58,21 +58,27 @@ describe('Cypress Project', () => {
it('should call init if cypress is not installed', async () => {
mockedInstalledCypressVersion.mockReturnValue(null);
await cypressProjectGenerator(tree, {
...defaultOptions,
name: 'my-app-e2e',
project: 'my-app',
projectNameAndRootFormat: 'as-provided',
});
expect(mockInitCypress).toHaveBeenCalled();
});
it('should call not init if cypress is installed', async () => {
mockedInstalledCypressVersion.mockReturnValue(10);
await cypressProjectGenerator(tree, {
...defaultOptions,
name: 'my-app-e2e',
project: 'my-app',
projectNameAndRootFormat: 'as-provided',
});
expect(mockInitCypress).not.toHaveBeenCalled();
});
@ -86,19 +92,15 @@ describe('Cypress Project', () => {
...defaultOptions,
name: 'my-app-e2e',
project: 'my-app',
projectNameAndRootFormat: 'as-provided',
});
expect(tree.exists('apps/my-app-e2e/cypress.config.ts')).toBeTruthy();
expect(
tree.exists('apps/my-app-e2e/src/fixtures/example.json')
).toBeTruthy();
expect(tree.exists('apps/my-app-e2e/src/e2e/app.cy.ts')).toBeTruthy();
expect(tree.exists('apps/my-app-e2e/src/support/app.po.ts')).toBeTruthy();
expect(
tree.exists('apps/my-app-e2e/src/support/commands.ts')
).toBeTruthy();
expect(tree.exists('apps/my-app-e2e/src/support/e2e.ts')).toBeTruthy();
expect(tree.exists('my-app-e2e/cypress.config.ts')).toBeTruthy();
expect(tree.exists('my-app-e2e/src/fixtures/example.json')).toBeTruthy();
expect(tree.exists('my-app-e2e/src/e2e/app.cy.ts')).toBeTruthy();
expect(tree.exists('my-app-e2e/src/support/app.po.ts')).toBeTruthy();
expect(tree.exists('my-app-e2e/src/support/commands.ts')).toBeTruthy();
expect(tree.exists('my-app-e2e/src/support/e2e.ts')).toBeTruthy();
});
it('should update configuration when eslint is passed', async () => {
@ -106,7 +108,9 @@ describe('Cypress Project', () => {
name: 'my-app-e2e',
project: 'my-app',
linter: Linter.EsLint,
projectNameAndRootFormat: 'as-provided',
});
const project = readProjectConfiguration(tree, 'my-app-e2e');
expect(project.targets.lint).toMatchSnapshot();
});
@ -116,7 +120,9 @@ describe('Cypress Project', () => {
name: 'my-app-e2e',
project: 'my-app',
linter: Linter.None,
projectNameAndRootFormat: 'as-provided',
});
const project = readProjectConfiguration(tree, 'my-app-e2e');
expect(project.targets.lint).toBeUndefined();
});
@ -126,6 +132,7 @@ describe('Cypress Project', () => {
name: 'my-app-e2e',
project: 'my-app',
linter: Linter.EsLint,
projectNameAndRootFormat: 'as-provided',
});
const project = readProjectConfiguration(tree, 'my-app-e2e');
@ -138,11 +145,10 @@ describe('Cypress Project', () => {
...defaultOptions,
name: 'my-app-e2e',
project: 'my-app',
projectNameAndRootFormat: 'as-provided',
});
const cypressConfig = tree.read(
'apps/my-app-e2e/cypress.config.ts',
'utf-8'
);
const cypressConfig = tree.read('my-app-e2e/cypress.config.ts', 'utf-8');
expect(cypressConfig).toMatchSnapshot();
});
@ -151,8 +157,10 @@ describe('Cypress Project', () => {
...defaultOptions,
name: 'my-app-e2e',
project: 'my-app',
projectNameAndRootFormat: 'as-provided',
});
const tsconfigJson = readJson(tree, 'apps/my-app-e2e/tsconfig.json');
const tsconfigJson = readJson(tree, 'my-app-e2e/tsconfig.json');
expect(tsconfigJson).toMatchSnapshot();
});
@ -161,10 +169,11 @@ describe('Cypress Project', () => {
...defaultOptions,
name: 'my-app-e2e',
project: 'my-app',
projectNameAndRootFormat: 'as-provided',
});
const tsConfig = readJson(tree, 'apps/my-app-e2e/tsconfig.json');
expect(tsConfig.extends).toBe('../../tsconfig.base.json');
const tsConfig = readJson(tree, 'my-app-e2e/tsconfig.json');
expect(tsConfig.extends).toBe('../tsconfig.base.json');
});
it('should support a root tsconfig.json instead of tsconfig.base.json', async () => {
@ -174,10 +183,11 @@ describe('Cypress Project', () => {
...defaultOptions,
name: 'my-app-e2e',
project: 'my-app',
projectNameAndRootFormat: 'as-provided',
});
const tsConfig = readJson(tree, 'apps/my-app-e2e/tsconfig.json');
expect(tsConfig.extends).toBe('../../tsconfig.json');
const tsConfig = readJson(tree, 'my-app-e2e/tsconfig.json');
expect(tsConfig.extends).toBe('../tsconfig.json');
});
describe('for bundler:vite', () => {
@ -187,9 +197,11 @@ describe('Cypress Project', () => {
name: 'my-app-e2e',
project: 'my-app',
bundler: 'vite',
projectNameAndRootFormat: 'as-provided',
});
const cypressConfig = tree.read(
'apps/my-app-e2e/cypress.config.ts',
'my-app-e2e/cypress.config.ts',
'utf-8'
);
expect(cypressConfig).toMatchSnapshot();
@ -202,11 +214,12 @@ describe('Cypress Project', () => {
...defaultOptions,
name: 'my-app-e2e',
project: 'my-dir-my-app',
directory: 'my-dir',
directory: 'my-dir/my-app-e2e',
projectNameAndRootFormat: 'as-provided',
});
const cypressConfig = tree.read(
'apps/my-dir/my-app-e2e/cypress.config.ts',
'my-dir/my-app-e2e/cypress.config.ts',
'utf-8'
);
expect(cypressConfig).toMatchSnapshot();
@ -217,13 +230,11 @@ describe('Cypress Project', () => {
...defaultOptions,
name: 'my-app-e2e',
project: 'my-dir-my-app',
directory: 'my-dir',
directory: 'my-dir/my-app-e2e',
projectNameAndRootFormat: 'as-provided',
});
const tsconfigJson = readJson(
tree,
'apps/my-dir/my-app-e2e/tsconfig.json'
);
const tsconfigJson = readJson(tree, 'my-dir/my-app-e2e/tsconfig.json');
expect(tsconfigJson).toMatchSnapshot();
});
@ -232,11 +243,12 @@ describe('Cypress Project', () => {
...defaultOptions,
name: 'my-app-e2e',
project: 'my-app',
directory: 'my-dir',
directory: 'my-dir/my-app-e2e',
projectNameAndRootFormat: 'as-provided',
});
const tsConfig = readJson(tree, 'apps/my-dir/my-app-e2e/tsconfig.json');
expect(tsConfig.extends).toBe('../../../tsconfig.base.json');
const tsConfig = readJson(tree, 'my-dir/my-app-e2e/tsconfig.json');
expect(tsConfig.extends).toBe('../../tsconfig.base.json');
});
it('should support a root tsconfig.json instead of tsconfig.base.json', async () => {
@ -246,24 +258,26 @@ describe('Cypress Project', () => {
...defaultOptions,
name: 'my-app-e2e',
project: 'my-app',
directory: 'my-dir',
directory: 'my-dir/my-app-e2e',
projectNameAndRootFormat: 'as-provided',
});
const tsConfig = readJson(tree, 'apps/my-dir/my-app-e2e/tsconfig.json');
expect(tsConfig.extends).toBe('../../../tsconfig.json');
const tsConfig = readJson(tree, 'my-dir/my-app-e2e/tsconfig.json');
expect(tsConfig.extends).toBe('../../tsconfig.json');
});
describe('root project', () => {
it('should generate in option.name when root project detected', async () => {
addProjectConfiguration(tree, 'root', {
root: '.',
});
addProjectConfiguration(tree, 'root', { root: '.' });
await cypressProjectGenerator(tree, {
...defaultOptions,
name: 'e2e-tests',
baseUrl: 'http://localhost:1234',
project: 'root',
projectNameAndRootFormat: 'as-provided',
});
expect(tree.listChanges().map((c) => c.path)).toEqual(
expect.arrayContaining([
'e2e-tests/cypress.config.ts',
@ -278,27 +292,26 @@ describe('Cypress Project', () => {
});
it('should not generate a root project when the passed in project is not the root project', async () => {
addProjectConfiguration(tree, 'root', {
root: '.',
});
addProjectConfiguration(tree, 'my-cool-app', {
root: 'apps/my-app',
});
addProjectConfiguration(tree, 'root', { root: '.' });
addProjectConfiguration(tree, 'my-cool-app', { root: 'my-cool-app' });
await cypressProjectGenerator(tree, {
...defaultOptions,
name: 'e2e-tests',
baseUrl: 'http://localhost:1234',
project: 'my-app',
project: 'my-cool-app',
projectNameAndRootFormat: 'as-provided',
});
expect(tree.listChanges().map((c) => c.path)).toEqual(
expect.arrayContaining([
'apps/e2e-tests/cypress.config.ts',
'apps/e2e-tests/src/e2e/app.cy.ts',
'apps/e2e-tests/src/fixtures/example.json',
'apps/e2e-tests/src/support/app.po.ts',
'apps/e2e-tests/src/support/commands.ts',
'apps/e2e-tests/src/support/e2e.ts',
'apps/e2e-tests/tsconfig.json',
'e2e-tests/cypress.config.ts',
'e2e-tests/src/e2e/app.cy.ts',
'e2e-tests/src/fixtures/example.json',
'e2e-tests/src/support/app.po.ts',
'e2e-tests/src/support/commands.ts',
'e2e-tests/src/support/e2e.ts',
'e2e-tests/tsconfig.json',
])
);
});
@ -312,6 +325,7 @@ describe('Cypress Project', () => {
...defaultOptions,
name: 'my-app-e2e',
baseUrl: 'http://localhost:7788',
projectNameAndRootFormat: 'as-provided',
});
const projectConfig = readProjectConfiguration(tree, 'my-app-e2e');
@ -323,12 +337,13 @@ describe('Cypress Project', () => {
it('should not throw an error when --project does not have targets', async () => {
const projectConf = readProjectConfiguration(tree, 'my-app');
delete projectConf.targets;
updateProjectConfiguration(tree, 'my-app', projectConf);
await cypressProjectGenerator(tree, {
name: 'my-app-e2e',
project: 'my-app',
linter: Linter.EsLint,
projectNameAndRootFormat: 'as-provided',
});
const projectConfig = readProjectConfiguration(tree, 'my-app-e2e');
@ -339,12 +354,31 @@ describe('Cypress Project', () => {
});
it('should generate in the correct folder', async () => {
await cypressProjectGenerator(tree, {
...defaultOptions,
name: 'one-two-other-e2e',
project: 'my-app',
directory: 'one/two/other-e2e',
projectNameAndRootFormat: 'as-provided',
});
const project = readProjectConfiguration(tree, 'one-two-other-e2e');
expect(project).toBeDefined();
[
'one/two/other-e2e/cypress.config.ts',
'one/two/other-e2e/src/e2e/app.cy.ts',
].forEach((path) => expect(tree.exists(path)).toBeTruthy());
});
it('should generate in the correct folder when --project-name-and-root-format=derived', async () => {
await cypressProjectGenerator(tree, {
...defaultOptions,
name: 'other-e2e',
project: 'my-app',
directory: 'one/two',
projectNameAndRootFormat: 'derived',
});
const project = readProjectConfiguration(tree, 'one-two-other-e2e');
expect(project).toBeDefined();
[
@ -369,6 +403,7 @@ describe('Cypress Project', () => {
...defaultOptions,
name: 'my-app-e2e',
project: 'my-app',
projectNameAndRootFormat: 'as-provided',
});
const e2eConfig = readProjectConfiguration(tree, 'my-app-e2e');
@ -388,6 +423,7 @@ describe('Cypress Project', () => {
...defaultOptions,
name: 'my-app-e2e',
project: 'my-app',
projectNameAndRootFormat: 'as-provided',
});
const e2eConfig = readProjectConfiguration(tree, 'my-app-e2e');
@ -400,26 +436,23 @@ describe('Cypress Project', () => {
beforeEach(() => {
mockedInstalledCypressVersion.mockReturnValue(9);
});
it('should generate files', async () => {
await cypressProjectGenerator(tree, {
...defaultOptions,
name: 'my-app-e2e',
project: 'my-app',
projectNameAndRootFormat: 'as-provided',
});
expect(tree.exists('apps/my-app-e2e/cypress.json')).toBeTruthy();
expect(tree.exists('my-app-e2e/cypress.json')).toBeTruthy();
expect(tree.exists('my-app-e2e/src/fixtures/example.json')).toBeTruthy();
expect(
tree.exists('apps/my-app-e2e/src/fixtures/example.json')
tree.exists('my-app-e2e/src/integration/app.spec.ts')
).toBeTruthy();
expect(
tree.exists('apps/my-app-e2e/src/integration/app.spec.ts')
).toBeTruthy();
expect(tree.exists('apps/my-app-e2e/src/support/app.po.ts')).toBeTruthy();
expect(
tree.exists('apps/my-app-e2e/src/support/commands.ts')
).toBeTruthy();
expect(tree.exists('apps/my-app-e2e/src/support/index.ts')).toBeTruthy();
expect(tree.exists('my-app-e2e/src/support/app.po.ts')).toBeTruthy();
expect(tree.exists('my-app-e2e/src/support/commands.ts')).toBeTruthy();
expect(tree.exists('my-app-e2e/src/support/index.ts')).toBeTruthy();
});
});
@ -433,39 +466,40 @@ describe('Cypress Project', () => {
...defaultOptions,
name: 'my-app-e2e',
project: 'my-app',
projectNameAndRootFormat: 'as-provided',
});
expect(tree.exists('apps/my-app-e2e/src/plugins/index.js')).toBeTruthy();
expect(tree.exists('my-app-e2e/src/plugins/index.js')).toBeTruthy();
});
it('should update configuration', async () => {
it('should update project configuration', async () => {
await cypressProjectGenerator(tree, {
name: 'my-app-e2e',
project: 'my-app',
linter: Linter.EsLint,
projectNameAndRootFormat: 'as-provided',
});
const project = readProjectConfiguration(tree, 'my-app-e2e');
expect(project.root).toEqual('apps/my-app-e2e');
expect(project.root).toEqual('my-app-e2e');
expect(project.targets).toMatchSnapshot();
});
it('should update configuration (baseUrl)', async () => {
it('should update project configuration (baseUrl)', async () => {
await cypressProjectGenerator(tree, {
name: 'my-app-e2e',
project: 'my-app',
baseUrl: 'http://localhost:3000',
linter: Linter.EsLint,
projectNameAndRootFormat: 'as-provided',
});
const project = readProjectConfiguration(tree, 'my-app-e2e');
expect(project.root).toEqual('apps/my-app-e2e');
expect(project.root).toEqual('my-app-e2e');
expect(project.targets).toMatchSnapshot();
});
it('should update configuration', async () => {
it('should update target configurations', async () => {
const originalProject = readProjectConfiguration(tree, 'my-app');
originalProject.targets.serve.defaultConfiguration = 'development';
originalProject.targets.serve.configurations.development = {};
@ -475,22 +509,22 @@ describe('Cypress Project', () => {
name: 'my-app-e2e',
project: 'my-app',
linter: Linter.EsLint,
projectNameAndRootFormat: 'as-provided',
});
const project = readProjectConfiguration(tree, 'my-app-e2e');
expect(project.root).toEqual('apps/my-app-e2e');
expect(project.root).toEqual('my-app-e2e');
expect(project.targets).toMatchSnapshot();
});
describe('nested', () => {
it('should update configuration', async () => {
await cypressProjectGenerator(tree, {
name: 'my-app-e2e',
name: 'my-dir-my-app-e2e',
project: 'my-dir-my-app',
directory: 'my-dir',
directory: 'my-dir/my-app-e2e',
linter: Linter.EsLint,
projectNameAndRootFormat: 'as-provided',
});
const projectConfig = readProjectConfiguration(
@ -509,13 +543,14 @@ describe('Cypress Project', () => {
name: 'my-app-e2e',
project: 'my-app',
linter: Linter.EsLint,
projectNameAndRootFormat: 'as-provided',
});
const packageJson = readJson(tree, 'package.json');
expect(
packageJson.devDependencies['eslint-plugin-cypress']
).toBeTruthy();
const eslintrcJson = readJson(tree, 'apps/my-app-e2e/.eslintrc.json');
const eslintrcJson = readJson(tree, 'my-app-e2e/.eslintrc.json');
expect(eslintrcJson).toMatchSnapshot();
});
});
@ -524,9 +559,11 @@ describe('Cypress Project', () => {
describe('project with directory in its name', () => {
beforeEach(async () => {
await cypressProjectGenerator(tree, {
name: 'my-dir/my-app-e2e',
name: 'my-dir-my-app-e2e',
project: 'my-dir-my-app',
directory: 'my-dir/my-app-e2e',
linter: Linter.EsLint,
projectNameAndRootFormat: 'as-provided',
});
});
@ -547,10 +584,9 @@ describe('Cypress Project', () => {
it('should set right path names in `cypress.json`', async () => {
const cypressConfig = tree.read(
'apps/my-dir/my-app-e2e/cypress.json',
'my-dir/my-app-e2e/cypress.json',
'utf-8'
);
expect(cypressConfig).toMatchSnapshot();
});
});

View File

@ -8,8 +8,8 @@ const cypressJsonConfig = {
fileServerFolder: '.',
fixturesFolder: './src/fixtures',
video: true,
videosFolder: '../../dist/cypress/apps/app-e2e/videos',
screenshotsFolder: '../../dist/cypress/apps/app-e2e/screenshots',
videosFolder: '../dist/cypress/app-e2e/videos',
screenshotsFolder: '../dist/cypress/app-e2e/screenshots',
chromeWebSecurity: false,
specPattern: 'src/e2e/**/*.cy.{js,jsx,ts,tsx}',
supportFile: 'src/support/e2e.ts',
@ -31,8 +31,8 @@ const cypressJsonConfig = {
fileServerFolder: '.',
fixturesFolder: './src/fixtures',
video: true,
videosFolder: '../../dist/cypress/apps/app-e2e/videos',
screenshotsFolder: '../../dist/cypress/apps/app-e2e/screenshots',
videosFolder: '../dist/cypress/app-e2e/videos',
screenshotsFolder: '../dist/cypress/app-e2e/screenshots',
chromeWebSecurity: false,
specPattern: 'src/e2e/**/*.cy.{js,jsx,ts,tsx}',
supportFile: 'src/support/e2e.ts',
@ -58,7 +58,7 @@ exports[`convertToCypressTen convertCypressProject should handle multiple config
},
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/app-e2e/cypress.config.ts",
"cypressConfig": "app-e2e/cypress.config.ts",
"devServerTarget": "app:serve",
"testingType": "e2e",
},
@ -73,8 +73,8 @@ const cypressJsonConfig = {
fileServerFolder: '.',
fixturesFolder: './src/fixtures',
video: true,
videosFolder: '../../dist/cypress/apps/app-e2e/videos',
screenshotsFolder: '../../dist/cypress/apps/app-e2e/screenshots',
videosFolder: '../dist/cypress/app-e2e/videos',
screenshotsFolder: '../dist/cypress/app-e2e/screenshots',
chromeWebSecurity: false,
specPattern: 'src/e2e/**/*.cy.{js,jsx,ts,tsx}',
supportFile: 'src/support/e2e.ts',
@ -92,12 +92,12 @@ exports[`convertToCypressTen convertCypressProject should handle multiple config
{
"configurations": {
"production": {
"cypressConfig": "apps/app-e2e/cypress.production.config.ts",
"cypressConfig": "app-e2e/cypress.production.config.ts",
"devServerTarget": "target:serve:production",
},
"static": {
"baseUrl": "http://localhost:3000",
"cypressConfig": "apps/app-e2e/cypress.config.ts",
"cypressConfig": "app-e2e/cypress.config.ts",
},
},
"executor": "@nx/cypress:cypress",
@ -137,8 +137,8 @@ const cypressJsonConfig = {
fileServerFolder: '.',
fixturesFolder: './src/fixtures',
video: true,
videosFolder: '../../dist/cypress/apps/app-e2e/videos',
screenshotsFolder: '../../dist/cypress/apps/app-e2e/screenshots',
videosFolder: '../dist/cypress/app-e2e/videos',
screenshotsFolder: '../dist/cypress/app-e2e/screenshots',
chromeWebSecurity: false,
specPattern: 'src/e2e/**/*.cy.{js,jsx,ts,tsx}',
supportFile: 'src/support/e2e.ts',
@ -162,7 +162,7 @@ exports[`convertToCypressTen convertCypressProject should infer targets with --a
},
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/app-e2e/cypress.config.ts",
"cypressConfig": "app-e2e/cypress.config.ts",
"devServerTarget": "app:serve",
"testingType": "e2e",
},
@ -175,7 +175,7 @@ exports[`convertToCypressTen convertCypressProject should infer targets with --a
},
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/app-e2e/cypress.config.ts",
"cypressConfig": "app-e2e/cypress.config.ts",
"devServerTarget": "app:serve",
"testingType": "e2e",
},
@ -184,7 +184,7 @@ exports[`convertToCypressTen convertCypressProject should infer targets with --a
"executor": "@nx/linter:eslint",
"options": {
"lintFilePatterns": [
"apps/app-e2e/**/*.{js,ts}",
"app-e2e/**/*.{js,ts}",
],
},
"outputs": [
@ -202,8 +202,8 @@ const cypressJsonConfig = {
fileServerFolder: '.',
fixturesFolder: './src/fixtures',
video: true,
videosFolder: '../../dist/cypress/apps/app-e2e/videos',
screenshotsFolder: '../../dist/cypress/apps/app-e2e/screenshots',
videosFolder: '../dist/cypress/app-e2e/videos',
screenshotsFolder: '../dist/cypress/app-e2e/screenshots',
chromeWebSecurity: false,
specPattern: 'src/e2e/**/*.cy.{js,jsx,ts,tsx}',
supportFile: 'src/support/e2e.ts',
@ -227,7 +227,7 @@ exports[`convertToCypressTen convertCypressProject should not break when an inva
},
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/app-e2e/cypress.config.ts",
"cypressConfig": "app-e2e/cypress.config.ts",
"devServerTarget": "app:serve",
"testingType": "e2e",
},
@ -240,7 +240,7 @@ exports[`convertToCypressTen convertCypressProject should not break when an inva
},
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/app-e2e/cypress.config.ts",
"cypressConfig": "app-e2e/cypress.config.ts",
"devServerTarget": "app:serve",
"testingType": "e2e",
},
@ -249,7 +249,7 @@ exports[`convertToCypressTen convertCypressProject should not break when an inva
"executor": "@nx/linter:eslint",
"options": {
"lintFilePatterns": [
"apps/app-e2e/**/*.{js,ts}",
"app-e2e/**/*.{js,ts}",
],
},
"outputs": [
@ -268,8 +268,8 @@ const cypressJsonConfig = {
fileServerFolder: '.',
fixturesFolder: './src/fixtures',
video: true,
videosFolder: '../../dist/cypress/apps/app-e2e/videos',
screenshotsFolder: '../../dist/cypress/apps/app-e2e/screenshots',
videosFolder: '../dist/cypress/app-e2e/videos',
screenshotsFolder: '../dist/cypress/app-e2e/screenshots',
chromeWebSecurity: false,
baseUrl: 'http://localhost:4200',
specPattern: 'src/e2e/**/*.cy.{js,jsx,ts,tsx}',
@ -293,8 +293,8 @@ const cypressJsonConfig = {
fileServerFolder: '.',
fixturesFolder: './src/fixtures',
video: true,
videosFolder: '../../dist/cypress/apps/app-e2e/videos',
screenshotsFolder: '../../dist/cypress/apps/app-e2e/screenshots',
videosFolder: '../dist/cypress/app-e2e/videos',
screenshotsFolder: '../dist/cypress/app-e2e/screenshots',
chromeWebSecurity: false,
specPattern: 'src/e2e/**/*.cy.{js,jsx,ts,tsx}',
supportFile: 'src/support/e2e.ts',

View File

@ -38,8 +38,8 @@ describe('convertToCypressTen', () => {
describe('convertCypressProject', () => {
beforeEach(async () => {
addProjectConfiguration(tree, 'app', {
root: 'apps/app',
sourceRoot: 'apps/app/src',
root: 'app',
sourceRoot: 'app/src',
targets: {
serve: {
executor: '@nx/web:file-server',
@ -53,31 +53,30 @@ describe('convertToCypressTen', () => {
name: 'app-e2e',
skipFormat: true,
project: 'app',
projectNameAndRootFormat: 'as-provided',
});
});
it('should update project w/defaults', async () => {
expect(tree.exists('apps/app-e2e/cypress.json')).toBeTruthy();
expect(tree.exists('app-e2e/cypress.json')).toBeTruthy();
await migrateCypressProject(tree);
expect(tree.exists('apps/app-e2e/cypress.config.ts')).toBeTruthy();
expect(
tree.read('apps/app-e2e/cypress.config.ts', 'utf-8')
).toMatchSnapshot();
expect(readJson(tree, 'apps/app-e2e/tsconfig.json').include).toEqual([
expect(tree.exists('app-e2e/cypress.config.ts')).toBeTruthy();
expect(tree.read('app-e2e/cypress.config.ts', 'utf-8')).toMatchSnapshot();
expect(readJson(tree, 'app-e2e/tsconfig.json').include).toEqual([
'src/**/*.ts',
'src/**/*.js',
'cypress.config.ts',
]);
expect(tree.exists('apps/app-e2e/src/e2e/app.cy.ts')).toBeTruthy();
expect(tree.exists('apps/app-e2e/src/support/e2e.ts')).toBeTruthy();
expect(tree.exists('app-e2e/src/e2e/app.cy.ts')).toBeTruthy();
expect(tree.exists('app-e2e/src/support/e2e.ts')).toBeTruthy();
});
it('should update project w/customized config', async () => {
expect(tree.exists('apps/app-e2e/cypress.json')).toBeTruthy();
expect(tree.exists('app-e2e/cypress.json')).toBeTruthy();
updateJson(tree, 'apps/app-e2e/cypress.json', (json) => {
updateJson(tree, 'app-e2e/cypress.json', (json) => {
json = {
...json,
baseUrl: 'http://localhost:4200',
@ -90,28 +89,26 @@ describe('convertToCypressTen', () => {
await migrateCypressProject(tree);
expect(tree.exists('apps/app-e2e/cypress.config.ts')).toBeTruthy();
expect(
tree.read('apps/app-e2e/cypress.config.ts', 'utf-8')
).toMatchSnapshot();
expect(readJson(tree, 'apps/app-e2e/tsconfig.json').include).toEqual([
expect(tree.exists('app-e2e/cypress.config.ts')).toBeTruthy();
expect(tree.read('app-e2e/cypress.config.ts', 'utf-8')).toMatchSnapshot();
expect(readJson(tree, 'app-e2e/tsconfig.json').include).toEqual([
'src/**/*.ts',
'src/**/*.js',
'cypress.config.ts',
]);
expect(tree.exists('apps/app-e2e/src/e2e/app.cy.ts')).toBeTruthy();
expect(tree.exists('apps/app-e2e/src/support/e2e.ts')).toBeTruthy();
expect(tree.exists('app-e2e/src/e2e/app.cy.ts')).toBeTruthy();
expect(tree.exists('app-e2e/src/support/e2e.ts')).toBeTruthy();
});
it('should not update a non e2e project', async () => {
await migrateCypressProject(tree);
expect(tree.exists('apps/app/cypress.config.ts')).toBeFalsy();
expect(tree.exists('apps/app/src/e2e/app.cy.ts')).toBeFalsy();
expect(tree.exists('apps/app/src/support/e2e.ts')).toBeFalsy();
expect(tree.exists('app/cypress.config.ts')).toBeFalsy();
expect(tree.exists('app/src/e2e/app.cy.ts')).toBeFalsy();
expect(tree.exists('app/src/support/e2e.ts')).toBeFalsy();
});
it('should handle custom target names', async () => {
expect(tree.exists('apps/app-e2e/cypress.json')).toBeTruthy();
expect(tree.exists('app-e2e/cypress.json')).toBeTruthy();
const pc = readProjectConfiguration(tree, 'app-e2e');
pc.targets = {
'e2e-custom': {
@ -123,21 +120,19 @@ describe('convertToCypressTen', () => {
await migrateCypressProject(tree);
expect(tree.exists('apps/app-e2e/cypress.config.ts')).toBeTruthy();
expect(
tree.read('apps/app-e2e/cypress.config.ts', 'utf-8')
).toMatchSnapshot();
expect(readJson(tree, 'apps/app-e2e/tsconfig.json').include).toEqual([
expect(tree.exists('app-e2e/cypress.config.ts')).toBeTruthy();
expect(tree.read('app-e2e/cypress.config.ts', 'utf-8')).toMatchSnapshot();
expect(readJson(tree, 'app-e2e/tsconfig.json').include).toEqual([
'src/**/*.ts',
'src/**/*.js',
'cypress.config.ts',
]);
expect(tree.exists('apps/app-e2e/src/e2e/app.cy.ts')).toBeTruthy();
expect(tree.exists('apps/app-e2e/src/support/e2e.ts')).toBeTruthy();
expect(tree.exists('app-e2e/src/e2e/app.cy.ts')).toBeTruthy();
expect(tree.exists('app-e2e/src/support/e2e.ts')).toBeTruthy();
});
it('should infer targets with --all flag', async () => {
expect(tree.exists('apps/app-e2e/cypress.json')).toBeTruthy();
expect(tree.exists('app-e2e/cypress.json')).toBeTruthy();
const pc = readProjectConfiguration(tree, 'app-e2e');
pc.targets = {
...pc.targets,
@ -150,24 +145,22 @@ describe('convertToCypressTen', () => {
await migrateCypressProject(tree);
expect(tree.exists('apps/app-e2e/cypress.config.ts')).toBeTruthy();
expect(
tree.read('apps/app-e2e/cypress.config.ts', 'utf-8')
).toMatchSnapshot();
expect(readJson(tree, 'apps/app-e2e/tsconfig.json').include).toEqual([
expect(tree.exists('app-e2e/cypress.config.ts')).toBeTruthy();
expect(tree.read('app-e2e/cypress.config.ts', 'utf-8')).toMatchSnapshot();
expect(readJson(tree, 'app-e2e/tsconfig.json').include).toEqual([
'src/**/*.ts',
'src/**/*.js',
'cypress.config.ts',
]);
expect(tree.exists('apps/app-e2e/src/e2e/app.cy.ts')).toBeTruthy();
expect(tree.exists('apps/app-e2e/src/support/e2e.ts')).toBeTruthy();
expect(tree.exists('app-e2e/src/e2e/app.cy.ts')).toBeTruthy();
expect(tree.exists('app-e2e/src/support/e2e.ts')).toBeTruthy();
expect(
readProjectConfiguration(tree, 'app-e2e').targets
).toMatchSnapshot();
});
it('should not break when an invalid target is passed in', async () => {
expect(tree.exists('apps/app-e2e/cypress.json')).toBeTruthy();
expect(tree.exists('app-e2e/cypress.json')).toBeTruthy();
const pc = readProjectConfiguration(tree, 'app-e2e');
pc.targets = {
...pc.targets,
@ -180,24 +173,22 @@ describe('convertToCypressTen', () => {
await migrateCypressProject(tree);
expect(tree.exists('apps/app-e2e/cypress.config.ts')).toBeTruthy();
expect(
tree.read('apps/app-e2e/cypress.config.ts', 'utf-8')
).toMatchSnapshot();
expect(readJson(tree, 'apps/app-e2e/tsconfig.json').include).toEqual([
expect(tree.exists('app-e2e/cypress.config.ts')).toBeTruthy();
expect(tree.read('app-e2e/cypress.config.ts', 'utf-8')).toMatchSnapshot();
expect(readJson(tree, 'app-e2e/tsconfig.json').include).toEqual([
'src/**/*.ts',
'src/**/*.js',
'cypress.config.ts',
]);
expect(tree.exists('apps/app-e2e/src/e2e/app.cy.ts')).toBeTruthy();
expect(tree.exists('apps/app-e2e/src/support/e2e.ts')).toBeTruthy();
expect(tree.exists('app-e2e/src/e2e/app.cy.ts')).toBeTruthy();
expect(tree.exists('app-e2e/src/support/e2e.ts')).toBeTruthy();
expect(
readProjectConfiguration(tree, 'app-e2e').targets
).toMatchSnapshot();
});
it('should handle multiple configurations', async () => {
expect(tree.exists('apps/app-e2e/cypress.json')).toBeTruthy();
expect(tree.exists('app-e2e/cypress.json')).toBeTruthy();
const pc = readProjectConfiguration(tree, 'app-e2e');
pc.targets = {
...pc.targets,
@ -218,26 +209,24 @@ describe('convertToCypressTen', () => {
await migrateCypressProject(tree);
expect(tree.exists('apps/app-e2e/cypress.config.ts')).toBeTruthy();
expect(
tree.read('apps/app-e2e/cypress.config.ts', 'utf-8')
).toMatchSnapshot();
expect(readJson(tree, 'apps/app-e2e/tsconfig.json').include).toEqual([
expect(tree.exists('app-e2e/cypress.config.ts')).toBeTruthy();
expect(tree.read('app-e2e/cypress.config.ts', 'utf-8')).toMatchSnapshot();
expect(readJson(tree, 'app-e2e/tsconfig.json').include).toEqual([
'src/**/*.ts',
'src/**/*.js',
'cypress.config.ts',
]);
expect(tree.exists('apps/app-e2e/src/e2e/app.cy.ts')).toBeTruthy();
expect(tree.exists('apps/app-e2e/src/support/e2e.ts')).toBeTruthy();
expect(tree.exists('app-e2e/src/e2e/app.cy.ts')).toBeTruthy();
expect(tree.exists('app-e2e/src/support/e2e.ts')).toBeTruthy();
expect(
readProjectConfiguration(tree, 'app-e2e').targets['e2e']
).toMatchSnapshot();
});
it('should handle multiple configurations with no default cypressConfig option', async () => {
expect(tree.exists('apps/app-e2e/cypress.json')).toBeTruthy();
expect(tree.exists('app-e2e/cypress.json')).toBeTruthy();
tree.write(
'apps/app-e2e/cypress.production.json',
'app-e2e/cypress.production.json',
JSON.stringify({
fileServerFolder: '.',
fixturesFolder: './src/fixtures',
@ -246,8 +235,8 @@ describe('convertToCypressTen', () => {
pluginsFile: './src/plugins/index',
supportFile: './src/support/index.ts',
video: true,
videosFolder: '../../dist/cypress/apps/client-e2e/videos',
screenshotsFolder: '../../dist/cypress/apps/client-e2e/screenshots',
videosFolder: '../dist/cypress/client-e2e/videos',
screenshotsFolder: '../dist/cypress/client-e2e/screenshots',
chromeWebSecurity: false,
})
);
@ -261,12 +250,12 @@ describe('convertToCypressTen', () => {
},
configurations: {
production: {
cypressConfig: 'apps/app-e2e/cypress.production.json',
cypressConfig: 'app-e2e/cypress.production.json',
devServerTarget: 'target:serve:production',
},
static: {
baseUrl: 'http://localhost:3000',
cypressConfig: 'apps/app-e2e/cypress.json',
cypressConfig: 'app-e2e/cypress.json',
},
},
},
@ -276,18 +265,16 @@ describe('convertToCypressTen', () => {
await migrateCypressProject(tree);
expect(tree.exists('apps/app-e2e/cypress.config.ts')).toBeTruthy();
expect(
tree.read('apps/app-e2e/cypress.config.ts', 'utf-8')
).toMatchSnapshot();
expect(readJson(tree, 'apps/app-e2e/tsconfig.json').include).toEqual([
expect(tree.exists('app-e2e/cypress.config.ts')).toBeTruthy();
expect(tree.read('app-e2e/cypress.config.ts', 'utf-8')).toMatchSnapshot();
expect(readJson(tree, 'app-e2e/tsconfig.json').include).toEqual([
'src/**/*.ts',
'src/**/*.js',
'cypress.production.config.ts',
'cypress.config.ts',
]);
expect(tree.exists('apps/app-e2e/src/e2e/app.cy.ts')).toBeTruthy();
expect(tree.exists('apps/app-e2e/src/support/e2e.ts')).toBeTruthy();
expect(tree.exists('app-e2e/src/e2e/app.cy.ts')).toBeTruthy();
expect(tree.exists('app-e2e/src/support/e2e.ts')).toBeTruthy();
expect(
readProjectConfiguration(tree, 'app-e2e').targets['e2e']
).toMatchSnapshot();
@ -296,8 +283,8 @@ describe('convertToCypressTen', () => {
it('should handle sharing the same config across projects', async () => {
mockedInstalledCypressVersion.mockReturnValue(9);
addProjectConfiguration(tree, 'app-two', {
root: 'apps/app-two',
sourceRoot: 'apps/app-two/src',
root: 'app-two',
sourceRoot: 'app-two/src',
targets: {
serve: {
executor: '@nx/web:file-server',
@ -310,6 +297,7 @@ describe('convertToCypressTen', () => {
name: 'app-two-e2e',
skipFormat: true,
project: 'app-two',
projectNameAndRootFormat: 'as-provided',
});
const appOneProjectConfig = readProjectConfiguration(tree, 'app-e2e');
appOneProjectConfig.targets['e2e'].options.cypressConfig = 'cypress.json';
@ -333,13 +321,13 @@ describe('convertToCypressTen', () => {
await migrateCypressProject(tree);
expect(tree.read('cypress.config.ts', 'utf-8')).toMatchSnapshot();
expect(readJson(tree, 'apps/app-e2e/tsconfig.json').include).toEqual([
expect(readJson(tree, 'app-e2e/tsconfig.json').include).toEqual([
'src/**/*.ts',
'src/**/*.js',
'../../cypress.config.ts',
'../cypress.config.ts',
]);
expect(tree.exists('apps/app-e2e/src/e2e/app.cy.ts')).toBeTruthy();
expect(tree.exists('apps/app-e2e/src/support/e2e.ts')).toBeTruthy();
expect(tree.exists('app-e2e/src/e2e/app.cy.ts')).toBeTruthy();
expect(tree.exists('app-e2e/src/support/e2e.ts')).toBeTruthy();
expect(readProjectConfiguration(tree, 'app-e2e').targets['e2e']).toEqual({
executor: '@nx/cypress:cypress',
options: {
@ -353,13 +341,13 @@ describe('convertToCypressTen', () => {
},
},
});
expect(readJson(tree, 'apps/app-two-e2e/tsconfig.json').include).toEqual([
expect(readJson(tree, 'app-two-e2e/tsconfig.json').include).toEqual([
'src/**/*.ts',
'src/**/*.js',
'../../cypress.config.ts',
'../cypress.config.ts',
]);
expect(tree.exists('apps/app-two-e2e/src/e2e/app.cy.ts')).toBeTruthy();
expect(tree.exists('apps/app-two-e2e/src/support/e2e.ts')).toBeTruthy();
expect(tree.exists('app-two-e2e/src/e2e/app.cy.ts')).toBeTruthy();
expect(tree.exists('app-two-e2e/src/support/e2e.ts')).toBeTruthy();
expect(
readProjectConfiguration(tree, 'app-two-e2e').targets['e2e']
).toEqual({
@ -393,8 +381,8 @@ describe('convertToCypressTen', () => {
};
const projectConfig = {
root: 'apps/app-e2e',
sourceRoot: 'apps/app-e2e/src',
root: 'app-e2e',
sourceRoot: 'app-e2e/src',
};
const filePaths = [
'src/integration/nested/something.spec.ts',
@ -486,9 +474,7 @@ const eh = require("../../support")
expect(newIntegrationFolderContents.length).toEqual(
oldIntegrationFolderContents.length
);
expect(tree.exists('apps/app-e2e/src/fixtures/example.json')).toEqual(
true
);
expect(tree.exists('app-e2e/src/fixtures/example.json')).toEqual(true);
});
it('should rename files', () => {
@ -513,7 +499,7 @@ const eh = require("../../support")
});
describe('updateImports', () => {
const filePath = 'apps/app-e2e/src/e2e/sometest.cy.ts';
const filePath = 'app-e2e/src/e2e/sometest.cy.ts';
const fileContents = String.raw`
import { getGreeting } from '../support/app.po';
@ -554,15 +540,15 @@ describe('a', () => {
});
describe('Support File Imports', () => {
const newImport = 'apps/app-e2e/src/support/e2e.ts';
const newImport = 'app-e2e/src/support/e2e.ts';
it('should update imports w/defaults', () => {
const oldImport = 'apps/app-e2e/src/support/index.ts';
const oldImport = 'app-e2e/src/support/index.ts';
const actual = createSupportFileImport(
oldImport,
newImport,
'apps/app-e2e/src'
'app-e2e/src'
);
expect(actual).toEqual({
oldImportPathLeaf: 'support',
@ -571,12 +557,12 @@ describe('a', () => {
});
it('should handle custom support file location', () => {
const oldImport = 'apps/app-e2e/src/support/blah.ts';
const oldImport = 'app-e2e/src/support/blah.ts';
const actual = createSupportFileImport(
oldImport,
newImport,
'apps/app-e2e/src'
'app-e2e/src'
);
expect(actual).toEqual({
oldImportPathLeaf: 'support/blah',
@ -585,12 +571,12 @@ describe('a', () => {
});
it('should handle nested custom support location', () => {
const oldImport = 'apps/app-e2e/src/support/blah/abc.ts';
const oldImport = 'app-e2e/src/support/blah/abc.ts';
const actual = createSupportFileImport(
oldImport,
newImport,
'apps/app-e2e/src'
'app-e2e/src'
);
expect(actual).toEqual({
oldImportPathLeaf: 'support/blah/abc',
@ -599,12 +585,12 @@ describe('a', () => {
});
it('should handle nested custom support location w/index.ts', () => {
const oldImport = 'apps/app-e2e/src/support/something/neat/index.ts';
const oldImport = 'app-e2e/src/support/something/neat/index.ts';
const actual = createSupportFileImport(
oldImport,
newImport,
'apps/app-e2e/src'
'app-e2e/src'
);
expect(actual).toEqual({
oldImportPathLeaf: 'support/something/neat',
@ -616,7 +602,7 @@ describe('a', () => {
describe(updatePluginFile.name, () => {
it('should update module.exports for ts files', () => {
tree.write(
'apps/app-e2e/src/plugins/index.ts',
'app-e2e/src/plugins/index.ts',
`
function myCoolFunction() {
console.log('cool')
@ -631,7 +617,7 @@ module.exports.blah = myCoolFunction;
);
const actual = updatePluginFile(
tree,
{ root: 'apps/app-e2e' },
{ root: 'app-e2e' },
{
cypressConfigJson: {},
cypressConfigTs: { e2e: { pluginsFile: './src/plugins/index.ts' } },
@ -641,7 +627,7 @@ module.exports.blah = myCoolFunction;
expect(actual.cypressConfigTs.e2e.pluginsFile).toEqual(
'./src/plugins/index'
);
expect(tree.read('apps/app-e2e/src/plugins/index.ts', 'utf-8')).toEqual(`
expect(tree.read('app-e2e/src/plugins/index.ts', 'utf-8')).toEqual(`
function myCoolFunction() {
console.log('cool')
}
@ -665,10 +651,10 @@ module.exports = function(on, config) {
module.exports.blah = myCoolFunction;
`;
tree.write('apps/app-e2e/src/plugins/index.js', pluginFileContent);
tree.write('app-e2e/src/plugins/index.js', pluginFileContent);
const actual = updatePluginFile(
tree,
{ root: 'apps/app-e2e' },
{ root: 'app-e2e' },
{
cypressConfigJson: {},
cypressConfigTs: { e2e: { pluginsFile: './src/plugins/index.js' } },
@ -678,7 +664,7 @@ module.exports.blah = myCoolFunction;
expect(actual.cypressConfigTs.e2e.pluginsFile).toEqual(
'./src/plugins/index'
);
expect(tree.read('apps/app-e2e/src/plugins/index.js', 'utf-8')).toEqual(
expect(tree.read('app-e2e/src/plugins/index.js', 'utf-8')).toEqual(
pluginFileContent
);
});
@ -686,7 +672,7 @@ module.exports.blah = myCoolFunction;
it('should not update if no file is preset', () => {
const actual = updatePluginFile(
tree,
{ root: 'apps/app-e2e' },
{ root: 'app-e2e' },
{
cypressConfigJson: {},
cypressConfigTs: { e2e: { pluginsFile: false } },
@ -694,7 +680,7 @@ module.exports.blah = myCoolFunction;
);
expect(actual.cypressConfigTs.e2e.pluginsFile).toBeFalsy();
expect(tree.exists('apps/app-e2e/src/plugins/index.ts')).toBeFalsy();
expect(tree.exists('app-e2e/src/plugins/index.ts')).toBeFalsy();
});
});
});