-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cypress/schematic): add support for component testing (#23385)
Co-authored-by: Jordan <jordan@jpdesigning.com>
- Loading branch information
1 parent
bd0d38f
commit 99562af
Showing
33 changed files
with
594 additions
and
114 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import Fixtures, { ProjectFixtureDir } from '@tooling/system-tests' | ||
import * as FixturesScaffold from '@tooling/system-tests/lib/dep-installer' | ||
import execa from 'execa' | ||
import path from 'path' | ||
import * as fs from 'fs-extra' | ||
|
||
const scaffoldAngularProject = async (project: string) => { | ||
const projectPath = Fixtures.projectPath(project) | ||
|
||
Fixtures.removeProject(project) | ||
await Fixtures.scaffoldProject(project) | ||
await FixturesScaffold.scaffoldProjectNodeModules(project) | ||
await fs.remove(path.join(projectPath, 'cypress.config.ts')) | ||
await fs.remove(path.join(projectPath, 'cypress')) | ||
|
||
return projectPath | ||
} | ||
|
||
const runCommandInProject = (command: string, projectPath: string) => { | ||
const [ex, ...args] = command.split(' ') | ||
|
||
return execa(ex, args, { cwd: projectPath, stdio: 'inherit' }) | ||
} | ||
|
||
const cypressSchematicPackagePath = path.join(__dirname, '..') | ||
|
||
const ANGULAR_PROJECTS: ProjectFixtureDir[] = ['angular-13', 'angular-14'] | ||
|
||
describe('ng add @cypress/schematic / e2e and ct', function () { | ||
this.timeout(1000 * 60 * 4) | ||
|
||
for (const project of ANGULAR_PROJECTS) { | ||
it('should install ct files with option and no component specs', async () => { | ||
const projectPath = await scaffoldAngularProject(project) | ||
|
||
await runCommandInProject(`yarn add @cypress/schematic@file:${cypressSchematicPackagePath}`, projectPath) | ||
await runCommandInProject('yarn ng add @cypress/schematic --e2e --component', projectPath) | ||
await runCommandInProject('yarn ng run angular:ct --watch false --spec src/app/app.component.cy.ts', projectPath) | ||
}) | ||
} | ||
}) |
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
19 changes: 19 additions & 0 deletions
19
npm/cypress-schematic/src/schematics/ng-add/files-core/cypress.config.ts.template
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,19 @@ | ||
import { defineConfig } from 'cypress' | ||
|
||
export default defineConfig({ | ||
<% if (e2e) { %> | ||
e2e: { | ||
'baseUrl': '<%= baseUrl%>', | ||
supportFile: false | ||
}, | ||
<% } %> | ||
<% if (component) { %> | ||
component: { | ||
devServer: { | ||
framework: 'angular', | ||
bundler: 'webpack', | ||
}, | ||
specPattern: '**/*.cy.ts' | ||
} | ||
<% } %> | ||
}) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...atics/ng-add/files/cypress/support/e2e.ts → .../ng-add/files-core/cypress/support/e2e.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
2 changes: 1 addition & 1 deletion
2
...matics/ng-add/files/cypress/tsconfig.json → ...s/ng-add/files-core/cypress/tsconfig.json
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
12 changes: 12 additions & 0 deletions
12
npm/cypress-schematic/src/schematics/ng-add/files-ct/component-index.html
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,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width,initial-scale=1.0"> | ||
<title>Components App</title> | ||
</head> | ||
<body> | ||
<div data-cy-root></div> | ||
</body> | ||
</html> |
Oops, something went wrong.