From a855cb0a8ab18bb99e9d1084b729a97a9d2e0751 Mon Sep 17 00:00:00 2001 From: thomas Date: Tue, 17 Oct 2023 23:12:53 +0200 Subject: [PATCH] feat(doc): move nested --- .../nested}/.eslintrc.json | 2 +- .../{testing-nested => test/nested}/README.md | 2 +- .../nested}/cypress.config.ts | 0 .../nested}/cypress/fixtures/example.json | 0 .../nested}/cypress/support/commands.ts | 0 .../cypress/support/component-index.html | 12 ++++++ .../nested}/cypress/support/component.ts | 0 .../nested}/cypress/tsconfig.json | 0 .../nested}/jest.config.ts | 4 +- .../nested}/project.json | 36 +++++++++--------- .../nested}/src/app/app.component.ts | 0 .../nested}/src/app/child.component.cy.ts | 0 .../nested}/src/app/child.component.spec.ts | 0 .../nested}/src/app/child.component.ts | 0 .../nested}/src/app/http.service.ts | 0 .../nested}/src/assets/.gitkeep | 0 .../nested}/src/favicon.ico | Bin .../nested}/src/index.html | 0 .../nested}/src/main.ts | 0 .../nested}/src/styles.scss | 0 .../nested}/src/test-setup.ts | 0 .../nested}/tsconfig.app.json | 2 +- .../nested}/tsconfig.editor.json | 0 .../nested}/tsconfig.json | 2 +- .../nested}/tsconfig.spec.json | 2 +- .../cypress/support/component-index.html | 13 ------- .../docs/challenges/testing/18-nested-comp.md | 8 ++-- 27 files changed, 41 insertions(+), 42 deletions(-) rename apps/{testing-nested => test/nested}/.eslintrc.json (89%) rename apps/{testing-nested => test/nested}/README.md (88%) rename apps/{testing-nested => test/nested}/cypress.config.ts (100%) rename apps/{testing-nested => test/nested}/cypress/fixtures/example.json (100%) rename apps/{testing-nested => test/nested}/cypress/support/commands.ts (100%) create mode 100644 apps/test/nested/cypress/support/component-index.html rename apps/{testing-nested => test/nested}/cypress/support/component.ts (100%) rename apps/{testing-nested => test/nested}/cypress/tsconfig.json (100%) rename apps/{testing-nested => test/nested}/jest.config.ts (89%) rename apps/{testing-nested => test/nested}/project.json (68%) rename apps/{testing-nested => test/nested}/src/app/app.component.ts (100%) rename apps/{testing-nested => test/nested}/src/app/child.component.cy.ts (100%) rename apps/{testing-nested => test/nested}/src/app/child.component.spec.ts (100%) rename apps/{testing-nested => test/nested}/src/app/child.component.ts (100%) rename apps/{testing-nested => test/nested}/src/app/http.service.ts (100%) rename apps/{testing-nested => test/nested}/src/assets/.gitkeep (100%) rename apps/{testing-nested => test/nested}/src/favicon.ico (100%) rename apps/{testing-nested => test/nested}/src/index.html (100%) rename apps/{testing-nested => test/nested}/src/main.ts (100%) rename apps/{testing-nested => test/nested}/src/styles.scss (100%) rename apps/{testing-nested => test/nested}/src/test-setup.ts (100%) rename apps/{testing-nested => test/nested}/tsconfig.app.json (89%) rename apps/{testing-nested => test/nested}/tsconfig.editor.json (100%) rename apps/{testing-nested => test/nested}/tsconfig.json (94%) rename apps/{testing-nested => test/nested}/tsconfig.spec.json (88%) delete mode 100644 apps/testing-nested/cypress/support/component-index.html diff --git a/apps/testing-nested/.eslintrc.json b/apps/test/nested/.eslintrc.json similarity index 89% rename from apps/testing-nested/.eslintrc.json rename to apps/test/nested/.eslintrc.json index e6e7ba6..bd48864 100644 --- a/apps/testing-nested/.eslintrc.json +++ b/apps/test/nested/.eslintrc.json @@ -1,5 +1,5 @@ { - "extends": ["../../.eslintrc.json"], + "extends": ["../../../.eslintrc.json"], "ignorePatterns": ["!**/*"], "overrides": [ { diff --git a/apps/testing-nested/README.md b/apps/test/nested/README.md similarity index 88% rename from apps/testing-nested/README.md rename to apps/test/nested/README.md index 1b7fea6..a5c37b1 100644 --- a/apps/testing-nested/README.md +++ b/apps/test/nested/README.md @@ -5,7 +5,7 @@ ### Run Application ```bash -npx nx serve testing-nested +npx nx serve test-nested ``` ### Documentation and Instruction diff --git a/apps/testing-nested/cypress.config.ts b/apps/test/nested/cypress.config.ts similarity index 100% rename from apps/testing-nested/cypress.config.ts rename to apps/test/nested/cypress.config.ts diff --git a/apps/testing-nested/cypress/fixtures/example.json b/apps/test/nested/cypress/fixtures/example.json similarity index 100% rename from apps/testing-nested/cypress/fixtures/example.json rename to apps/test/nested/cypress/fixtures/example.json diff --git a/apps/testing-nested/cypress/support/commands.ts b/apps/test/nested/cypress/support/commands.ts similarity index 100% rename from apps/testing-nested/cypress/support/commands.ts rename to apps/test/nested/cypress/support/commands.ts diff --git a/apps/test/nested/cypress/support/component-index.html b/apps/test/nested/cypress/support/component-index.html new file mode 100644 index 0000000..ee5b073 --- /dev/null +++ b/apps/test/nested/cypress/support/component-index.html @@ -0,0 +1,12 @@ + + + + + + + testing-nested Components App + + +
+ + diff --git a/apps/testing-nested/cypress/support/component.ts b/apps/test/nested/cypress/support/component.ts similarity index 100% rename from apps/testing-nested/cypress/support/component.ts rename to apps/test/nested/cypress/support/component.ts diff --git a/apps/testing-nested/cypress/tsconfig.json b/apps/test/nested/cypress/tsconfig.json similarity index 100% rename from apps/testing-nested/cypress/tsconfig.json rename to apps/test/nested/cypress/tsconfig.json diff --git a/apps/testing-nested/jest.config.ts b/apps/test/nested/jest.config.ts similarity index 89% rename from apps/testing-nested/jest.config.ts rename to apps/test/nested/jest.config.ts index d4e125d..a379ad5 100644 --- a/apps/testing-nested/jest.config.ts +++ b/apps/test/nested/jest.config.ts @@ -1,7 +1,7 @@ /* eslint-disable */ export default { - displayName: 'testing-nested', - preset: '../../jest.preset.js', + displayName: 'test-nested', + preset: '../../../jest.preset.js', setupFilesAfterEnv: ['/src/test-setup.ts'], transform: { '^.+\\.(ts|mjs|js|html)$': [ diff --git a/apps/testing-nested/project.json b/apps/test/nested/project.json similarity index 68% rename from apps/testing-nested/project.json rename to apps/test/nested/project.json index 6be8011..487eb15 100644 --- a/apps/testing-nested/project.json +++ b/apps/test/nested/project.json @@ -1,25 +1,25 @@ { - "name": "testing-nested", - "$schema": "../node_modules/nx/schemas/project-schema.json", + "name": "test-nested", + "$schema": "../../../node_modules/nx/schemas/project-schema.json", "projectType": "application", - "sourceRoot": "apps/testing-nested/src", + "sourceRoot": "apps/test/nested/src", "prefix": "app", "targets": { "build": { "executor": "@angular-devkit/build-angular:browser", "outputs": ["{options.outputPath}"], "options": { - "outputPath": "dist/apps/testing-nested", - "index": "apps/testing-nested/src/index.html", - "main": "apps/testing-nested/src/main.ts", + "outputPath": "dist/apps/test/nested", + "index": "apps/test/nested/src/index.html", + "main": "apps/test/nested/src/main.ts", "polyfills": ["zone.js"], - "tsConfig": "apps/testing-nested/tsconfig.app.json", + "tsConfig": "apps/test/nested/tsconfig.app.json", "inlineStyleLanguage": "scss", "assets": [ - "apps/testing-nested/src/favicon.ico", - "apps/testing-nested/src/assets" + "apps/test/nested/src/favicon.ico", + "apps/test/nested/src/assets" ], - "styles": ["apps/testing-nested/src/styles.scss"], + "styles": ["apps/test/nested/src/styles.scss"], "scripts": [] }, "configurations": { @@ -53,10 +53,10 @@ "executor": "@angular-devkit/build-angular:dev-server", "configurations": { "production": { - "browserTarget": "testing-nested:build:production" + "browserTarget": "test-nested:build:production" }, "development": { - "browserTarget": "testing-nested:build:development" + "browserTarget": "test-nested:build:development" } }, "defaultConfiguration": "development" @@ -64,7 +64,7 @@ "extract-i18n": { "executor": "@angular-devkit/build-angular:extract-i18n", "options": { - "browserTarget": "testing-nested:build" + "browserTarget": "test-nested:build" } }, "lint": { @@ -72,8 +72,8 @@ "outputs": ["{options.outputFile}"], "options": { "lintFilePatterns": [ - "apps/testing-nested/**/*.ts", - "apps/testing-nested/**/*.html" + "apps/test/nested/**/*.ts", + "apps/test/nested/**/*.html" ] } }, @@ -81,7 +81,7 @@ "executor": "@nx/jest:jest", "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], "options": { - "jestConfig": "apps/testing-nested/jest.config.ts", + "jestConfig": "apps/test/nested/jest.config.ts", "passWithNoTests": true }, "configurations": { @@ -94,10 +94,10 @@ "component-test": { "executor": "@nx/cypress:cypress", "options": { - "cypressConfig": "apps/testing-nested/cypress.config.ts", + "cypressConfig": "apps/test/nested/cypress.config.ts", "testingType": "component", "skipServe": true, - "devServerTarget": "testing-nested:build" + "devServerTarget": "test-nested:build" } } }, diff --git a/apps/testing-nested/src/app/app.component.ts b/apps/test/nested/src/app/app.component.ts similarity index 100% rename from apps/testing-nested/src/app/app.component.ts rename to apps/test/nested/src/app/app.component.ts diff --git a/apps/testing-nested/src/app/child.component.cy.ts b/apps/test/nested/src/app/child.component.cy.ts similarity index 100% rename from apps/testing-nested/src/app/child.component.cy.ts rename to apps/test/nested/src/app/child.component.cy.ts diff --git a/apps/testing-nested/src/app/child.component.spec.ts b/apps/test/nested/src/app/child.component.spec.ts similarity index 100% rename from apps/testing-nested/src/app/child.component.spec.ts rename to apps/test/nested/src/app/child.component.spec.ts diff --git a/apps/testing-nested/src/app/child.component.ts b/apps/test/nested/src/app/child.component.ts similarity index 100% rename from apps/testing-nested/src/app/child.component.ts rename to apps/test/nested/src/app/child.component.ts diff --git a/apps/testing-nested/src/app/http.service.ts b/apps/test/nested/src/app/http.service.ts similarity index 100% rename from apps/testing-nested/src/app/http.service.ts rename to apps/test/nested/src/app/http.service.ts diff --git a/apps/testing-nested/src/assets/.gitkeep b/apps/test/nested/src/assets/.gitkeep similarity index 100% rename from apps/testing-nested/src/assets/.gitkeep rename to apps/test/nested/src/assets/.gitkeep diff --git a/apps/testing-nested/src/favicon.ico b/apps/test/nested/src/favicon.ico similarity index 100% rename from apps/testing-nested/src/favicon.ico rename to apps/test/nested/src/favicon.ico diff --git a/apps/testing-nested/src/index.html b/apps/test/nested/src/index.html similarity index 100% rename from apps/testing-nested/src/index.html rename to apps/test/nested/src/index.html diff --git a/apps/testing-nested/src/main.ts b/apps/test/nested/src/main.ts similarity index 100% rename from apps/testing-nested/src/main.ts rename to apps/test/nested/src/main.ts diff --git a/apps/testing-nested/src/styles.scss b/apps/test/nested/src/styles.scss similarity index 100% rename from apps/testing-nested/src/styles.scss rename to apps/test/nested/src/styles.scss diff --git a/apps/testing-nested/src/test-setup.ts b/apps/test/nested/src/test-setup.ts similarity index 100% rename from apps/testing-nested/src/test-setup.ts rename to apps/test/nested/src/test-setup.ts diff --git a/apps/testing-nested/tsconfig.app.json b/apps/test/nested/tsconfig.app.json similarity index 89% rename from apps/testing-nested/tsconfig.app.json rename to apps/test/nested/tsconfig.app.json index e46d4fc..01a02ed 100644 --- a/apps/testing-nested/tsconfig.app.json +++ b/apps/test/nested/tsconfig.app.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "outDir": "../../../dist/out-tsc", "types": [] }, "files": ["src/main.ts"], diff --git a/apps/testing-nested/tsconfig.editor.json b/apps/test/nested/tsconfig.editor.json similarity index 100% rename from apps/testing-nested/tsconfig.editor.json rename to apps/test/nested/tsconfig.editor.json diff --git a/apps/testing-nested/tsconfig.json b/apps/test/nested/tsconfig.json similarity index 94% rename from apps/testing-nested/tsconfig.json rename to apps/test/nested/tsconfig.json index 28546c4..3879b94 100644 --- a/apps/testing-nested/tsconfig.json +++ b/apps/test/nested/tsconfig.json @@ -25,7 +25,7 @@ "path": "./cypress/tsconfig.json" } ], - "extends": "../../tsconfig.base.json", + "extends": "../../../tsconfig.base.json", "angularCompilerOptions": { "enableI18nLegacyMessageIdFormat": false, "strictInjectionParameters": true, diff --git a/apps/testing-nested/tsconfig.spec.json b/apps/test/nested/tsconfig.spec.json similarity index 88% rename from apps/testing-nested/tsconfig.spec.json rename to apps/test/nested/tsconfig.spec.json index 1a4817a..c0c092e 100644 --- a/apps/testing-nested/tsconfig.spec.json +++ b/apps/test/nested/tsconfig.spec.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "outDir": "../../../dist/out-tsc", "module": "commonjs", "types": ["jest", "node", "@testing-library/jest-dom"] }, diff --git a/apps/testing-nested/cypress/support/component-index.html b/apps/testing-nested/cypress/support/component-index.html deleted file mode 100644 index b92f178..0000000 --- a/apps/testing-nested/cypress/support/component-index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - testing-nested Components App - - - -
- - diff --git a/docs/src/content/docs/challenges/testing/18-nested-comp.md b/docs/src/content/docs/challenges/testing/18-nested-comp.md index 02c539f..113b22e 100644 --- a/docs/src/content/docs/challenges/testing/18-nested-comp.md +++ b/docs/src/content/docs/challenges/testing/18-nested-comp.md @@ -3,7 +3,7 @@ title: 🟠 Nested Components description: Challenge 18 is about testing nested components author: Thomas Laforge challengeNumber: 18 -command: testing-nested +command: test-nested sidebar: order: 109 --- @@ -14,11 +14,11 @@ We have a small application that sends a title, typed into an input to a fake ba If the title is correctly typed, you can send the request otherwise you receive an error and the request is not sent. The application is created with nested components. `ChildComponent` is the container that includes four components: `ResultComponent`, `ButtonComponent`, `InputComponent` and `ErrorComponent`. However since we are testing our component as a black box, the architecture of our components doesn't change anything. You can create your test, change how the components are structured, and your tests should still pass. That's the goal of integration tests. Never test internal implementation details!!!. -You can play with it by running : `npx nx serve testing-nested`. +You can play with it by running : `npx nx serve test-nested`. -The file named `child.component.spec.ts` will let test your application using Testing Library. To run the test suits, you need to run `npx nx test testing-nested`. You can also install [Jest Runner](https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner) to execute your test by clicking on the `Run` button above each `describe` or `it` blocks. +The file named `child.component.spec.ts` will let test your application using Testing Library. To run the test suits, you need to run `npx nx test test-nested`. You can also install [Jest Runner](https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner) to execute your test by clicking on the `Run` button above each `describe` or `it` blocks. -For testing cypress, you will execute your test inside the `child.component.cy.ts` and run `npx nx component-test testing-nested` to execute your test suits. You can add the `--watch` flag to execute your test in watch mode. +For testing cypress, you will execute your test inside the `child.component.cy.ts` and run `npx nx component-test test-nested` to execute your test suits. You can add the `--watch` flag to execute your test in watch mode. # Statement