Skip to content

Commit 3027f38

Browse files
committed
First commit
0 parents  commit 3027f38

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+33185
-0
lines changed

.editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Editor configuration, see http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
max_line_length = off
13+
trim_trailing_whitespace = false

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.eslintrc.json

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"root": true,
3+
"ignorePatterns": ["**/*"],
4+
"plugins": ["@nx"],
5+
"overrides": [
6+
{
7+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
8+
"rules": {
9+
"@nx/enforce-module-boundaries": [
10+
"error",
11+
{
12+
"enforceBuildableLibDependency": true,
13+
"allow": [],
14+
"depConstraints": [
15+
{
16+
"sourceTag": "*",
17+
"onlyDependOnLibsWithTags": ["*"]
18+
}
19+
]
20+
}
21+
]
22+
}
23+
},
24+
{
25+
"files": ["*.ts", "*.tsx"],
26+
"extends": ["plugin:@nx/typescript"],
27+
"rules": {}
28+
},
29+
{
30+
"files": ["*.js", "*.jsx"],
31+
"extends": ["plugin:@nx/javascript"],
32+
"rules": {}
33+
},
34+
{
35+
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
36+
"env": {
37+
"jest": true
38+
},
39+
"rules": {}
40+
}
41+
]
42+
}

.gitignore

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# compiled output
4+
dist
5+
tmp
6+
/out-tsc
7+
8+
# dependencies
9+
node_modules
10+
11+
# IDEs and editors
12+
/.idea
13+
.project
14+
.classpath
15+
.c9/
16+
*.launch
17+
.settings/
18+
*.sublime-workspace
19+
20+
# IDE - VSCode
21+
.vscode/*
22+
!.vscode/settings.json
23+
!.vscode/tasks.json
24+
!.vscode/launch.json
25+
!.vscode/extensions.json
26+
27+
# misc
28+
/.sass-cache
29+
/connect.lock
30+
/coverage
31+
/libpeerconnection.log
32+
npm-debug.log
33+
yarn-error.log
34+
testem.log
35+
/typings
36+
37+
# System Files
38+
.DS_Store
39+
Thumbs.db
40+
41+
.angular
42+
43+
# Coverage
44+
**/**/.nyc_output
45+
**/**/coverage

.prettierignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Add files here to ignore them from prettier formatting
2+
/dist
3+
/coverage
4+
.angular

.prettierrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": true
3+
}

README.md

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
## Create NX Workspace
2+
3+
```
4+
npx create-nx-workspace@latest
5+
```
6+
7+
Reply "NO" standalone components and "YES" to routing
8+
9+
## Install Dependencies
10+
11+
```
12+
npm i ngx-build-plus @cypress/code-coverage @istanbuljs/nyc-config-typescript @jsdevtools/coverage-istanbul-loader istanbul-lib-coverage nyc --save-dev
13+
```
14+
15+
## Create Webpack config
16+
17+
Create a `webpack.coverage.js` file in the root of your nx workspace. And add this config:
18+
19+
```
20+
const path = require('path');
21+
22+
module.exports = {
23+
module: {
24+
rules: [
25+
{
26+
test: /\.(js|ts)$/,
27+
loader: '@jsdevtools/coverage-istanbul-loader',
28+
options: { esModules: true },
29+
enforce: 'post',
30+
include: [path.join(__dirname, '{your-app-directory}')],
31+
exclude: [/\.(cy|spec)\.ts$/, /node_modules/],
32+
},
33+
],
34+
},
35+
};
36+
```
37+
38+
## Modify your app project.json
39+
40+
Open your app `project.json` and add this to `targets`:
41+
42+
```
43+
"serve-nx-demo-app-e2e": {
44+
"executor": "ngx-build-plus:dev-server",
45+
"defaultConfiguration": "",
46+
"options": {
47+
"browserTarget": "{your-app-directory}:build:development",
48+
"extraWebpackConfig": "./webpack.coverage.js",
49+
"port": 3000
50+
}
51+
}
52+
```
53+
54+
## Modify your e2e project.json
55+
56+
Add a new configuration to add coverage inside `targets.e2e.configurations`:
57+
58+
```
59+
"coverage": {
60+
"devServerTarget": "{your-app-directory}:serve-nx-demo-app-e2e"
61+
}
62+
```
63+
64+
## Import cypress code coverage library
65+
66+
Open `apps/your-app-directory-e2e/src/support/e2e.ts` and add this line:
67+
68+
```
69+
import '@cypress/code-coverage/support';
70+
```
71+
72+
## Update cypress.config.ts
73+
74+
Open `apps/your-app-directory-e2e/cypress.config.ts` and replace it with this:
75+
76+
```
77+
import { defineConfig } from 'cypress';
78+
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
79+
80+
export default defineConfig({
81+
e2e: {
82+
...nxE2EPreset(__dirname),
83+
setupNodeEvents(on, config) {
84+
// eslint-disable-next-line @typescript-eslint/no-var-requires
85+
require('@cypress/code-coverage/task')(on, config);
86+
return config;
87+
}
88+
}
89+
});
90+
```
91+
92+
Run `nx e2e nx-demo-app-e2e --configuration=coverage` to generate your coverage then open in your browser `apps/your-app-directory-e2e/coverage/lcov-report/index.html` to view your coverage results.

apps/.gitkeep

Whitespace-only changes.

apps/nx-demo-app-e2e/.eslintrc.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": ["plugin:cypress/recommended", "../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
}
9+
]
10+
}
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { defineConfig } from 'cypress';
2+
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
3+
4+
export default defineConfig({
5+
e2e: {
6+
...nxE2EPreset(__dirname),
7+
setupNodeEvents(on, config) {
8+
// eslint-disable-next-line @typescript-eslint/no-var-requires
9+
require('@cypress/code-coverage/task')(on, config);
10+
// include any other plugin code...
11+
12+
// It's IMPORTANT to return the config object
13+
// with any changed environment variables
14+
return config;
15+
}
16+
}
17+
});

apps/nx-demo-app-e2e/project.json

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "nx-demo-app-e2e",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "apps/nx-demo-app-e2e/src",
5+
"projectType": "application",
6+
"targets": {
7+
"e2e": {
8+
"executor": "@nx/cypress:cypress",
9+
"options": {
10+
"cypressConfig": "apps/nx-demo-app-e2e/cypress.config.ts",
11+
"devServerTarget": "nx-demo-app:serve:development",
12+
"testingType": "e2e"
13+
},
14+
"configurations": {
15+
"production": {
16+
"devServerTarget": "nx-demo-app:serve:production"
17+
},
18+
"ci": {
19+
"devServerTarget": "nx-demo-app:serve-static"
20+
},
21+
"coverage": {
22+
"devServerTarget": "nx-demo-app:serve-nx-demo-app-e2e"
23+
}
24+
}
25+
},
26+
"lint": {
27+
"executor": "@nx/linter:eslint",
28+
"outputs": ["{options.outputFile}"],
29+
"options": {
30+
"lintFilePatterns": ["apps/nx-demo-app-e2e/**/*.{js,ts}"]
31+
}
32+
}
33+
},
34+
"tags": [],
35+
"implicitDependencies": ["nx-demo-app"]
36+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { getGreeting } from '../support/app.po';
2+
3+
describe('nx-demo-app', () => {
4+
beforeEach(() => cy.visit('/'));
5+
6+
it('should display welcome message', () => {
7+
// Custom command example, see `../support/commands.ts` file
8+
cy.login('[email protected]', 'myPassword');
9+
10+
// Function helper example, see `../support/app.po.ts` file
11+
getGreeting().contains('Welcome nx-demo-app');
12+
});
13+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "[email protected]"
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const getGreeting = () => cy.get('h1');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// ***********************************************
2+
// This example commands.js shows you how to
3+
// create various custom commands and overwrite
4+
// existing commands.
5+
//
6+
// For more comprehensive examples of custom
7+
// commands please read more here:
8+
// https://on.cypress.io/custom-commands
9+
// ***********************************************
10+
11+
// eslint-disable-next-line @typescript-eslint/no-namespace
12+
declare namespace Cypress {
13+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
14+
interface Chainable<Subject> {
15+
login(email: string, password: string): void;
16+
}
17+
}
18+
//
19+
// -- This is a parent command --
20+
Cypress.Commands.add('login', (email, password) => {
21+
console.log('Custom command example: Login', email, password);
22+
});
23+
//
24+
// -- This is a child command --
25+
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
26+
//
27+
//
28+
// -- This is a dual command --
29+
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
30+
//
31+
//
32+
// -- This will overwrite an existing command --
33+
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// ***********************************************************
2+
// This example support/index.js is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
15+
16+
// Import commands.js using ES2015 syntax:
17+
import './commands';
18+
import '@cypress/code-coverage/support';

apps/nx-demo-app-e2e/tsconfig.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"sourceMap": false,
5+
"outDir": "../../dist/out-tsc",
6+
"allowJs": true,
7+
"types": ["cypress", "node"],
8+
"forceConsistentCasingInFileNames": true,
9+
"strict": true,
10+
"noImplicitOverride": true,
11+
"noPropertyAccessFromIndexSignature": true,
12+
"noImplicitReturns": true,
13+
"noFallthroughCasesInSwitch": true
14+
},
15+
"include": ["src/**/*.ts", "src/**/*.js", "cypress.config.ts"]
16+
}

0 commit comments

Comments
 (0)