diff --git a/.all-contributorsrc b/.all-contributorsrc index 78b7aad7..78360b45 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -207,6 +207,15 @@ "code", "ideas" ] + }, + { + "login": "amitmiran137", + "name": "Amit Miran", + "avatar_url": "https://avatars.githubusercontent.com/u/47772523?v=4", + "profile": "https://github.com/amitmiran137", + "contributions": [ + "infra" + ] } ], "contributorsPerLine": 7, diff --git a/.eslintrc.json b/.eslintrc.json index b740f815..74ab4641 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -5,9 +5,6 @@ "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "parserOptions": { - "project": ["/tsconfig.*?.json"] - }, "rules": { "@nrwl/nx/enforce-module-boundaries": [ "error", @@ -49,7 +46,7 @@ ], "@typescript-eslint/no-unused-expressions": "error", "@typescript-eslint/prefer-function-type": "error", - "@typescript-eslint/quotes": ["error", "single"], + "@typescript-eslint/quotes": "off", "@typescript-eslint/type-annotation-spacing": "error", "@typescript-eslint/no-explicit-any": "off", "arrow-body-style": "error", @@ -107,9 +104,10 @@ }, { "files": ["*.spec.ts"], - "extends": ["plugin:testing-library/angular", "plugin:jest-dom/recommended"], + "extends": ["plugin:jest/recommended"], "rules": { - "testing-library/prefer-explicit-assert": "error" + "jest/no-done-callback": "off", + "jest/expect-expect": "off" } }, { diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ee20df6..d731bd75 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,17 +1,22 @@ name: ci -on: pull_request +on: + push: + pull_request: + branches: + - main jobs: - build_and_test: + build_test_release: strategy: matrix: os: [ubuntu-latest, windows-latest] - node: [12, 14, 16] + node-version: [12, 14] runs-on: ${{ matrix.os }} + steps: - uses: actions/checkout@v2 - - name: use Node.js ${{ matrix.node-version }} + - name: use Node.js ${{ matrix.node-version }} on ${{ matrix.os }} uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} @@ -21,3 +26,9 @@ jobs: run: npm run build -- --skip-nx-cache - name: test run: npm run test -- --ci --code-coverage + - name: Release + if: github.repository == 'testing-library/angular-testing-library' && github.ref == 'refs/heads/main' && matrix.node-version == 14 && matrix.os == 'ubuntu-latest' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npx semantic-release diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 0370418d..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: release - -on: - push: - branches: - - master - -jobs: - release: - if: github.repository == 'testing-library/angular-testing-library' - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [12.x] - - steps: - - uses: actions/checkout@v1 - - name: use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - name: install - run: npm install - - name: build - run: npm run build -- --skip-nx-cache - - name: test - run: npm run test -- --ci --code-coverage - - name: Release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - run: npx semantic-release diff --git a/README.md b/README.md index b542de69..e7788a2c 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ height="80" width="80" alt="hedgehog" - src="https://raw.githubusercontent.com/testing-library/angular-testing-library/master/other/hedgehog.png" + src="https://raw.githubusercontent.com/testing-library/angular-testing-library/main/other/hedgehog.png" /> @@ -43,7 +43,7 @@ practices.

TestingJavaScript.com Learn the smart, efficient way to test any JavaScript application. @@ -139,7 +139,7 @@ describe('Counter', () => { }); ``` -[See more examples](https://github.com/testing-library/angular-testing-library/tree/master/apps/example-app/src/app/examples) +[See more examples](https://github.com/testing-library/angular-testing-library/tree/main/apps/example-app/src/app/examples) ## Installation @@ -211,6 +211,9 @@ Thanks goes to these people ([emoji key][emojis]):
Arjen

💻
Suguru Inatomi

💻 🤔 + +
Amit Miran

🚇 + @@ -270,8 +273,8 @@ Links: [npm]: https://www.npmjs.com/ [node]: https://nodejs.org -[build-badge]: https://circleci.com/gh/testing-library/angular-testing-library/tree/master.svg?style=shield -[build]: https://circleci.com/gh/testing-library/angular-testing-library/tree/master +[build-badge]: https://circleci.com/gh/testing-library/angular-testing-library/tree/main.svg?style=shield +[build]: https://circleci.com/gh/testing-library/angular-testing-library/tree/main [coverage]: https://codecov.io/github/testing-library/angular-testing-library [coverage-badge]: https://img.shields.io/codecov/c/github/testing-library/angular-testing-library.svg?style=flat-square [version-badge]: https://img.shields.io/npm/v/@testing-library/angular.svg?style=flat-square @@ -281,12 +284,12 @@ Links: [discord-badge]: https://img.shields.io/discord/723559267868737556.svg?color=7389D8&labelColor=6A7EC2&logo=discord&logoColor=ffffff&style=flat-square [discord]: https://discord.gg/testing-library [license-badge]: https://img.shields.io/npm/l/@testing-library/angular.svg?style=flat-square -[license]: https://github.com/testing-library/angular-testing-library/blob/master/LICENSE +[license]: https://github.com/testing-library/angular-testing-library/blob/main/LICENSE [prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square [prs]: http://makeapullrequest.com [donate-badge]: https://img.shields.io/badge/$-support-green.svg?style=flat-square [coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square -[coc]: https://github.com/testing-library/angular-testing-library/blob/master/CODE_OF_CONDUCT.md +[coc]: https://github.com/testing-library/angular-testing-library/blob/main/CODE_OF_CONDUCT.md [github-watch-badge]: https://img.shields.io/github/watchers/testing-library/angular-testing-library.svg?style=social [github-watch]: https://github.com/testing-library/angular-testing-library/watchers [github-star-badge]: https://img.shields.io/github/stars/testing-library/angular-testing-library.svg?style=social diff --git a/angular.json b/angular.json index 46f51c32..3e8b2f12 100644 --- a/angular.json +++ b/angular.json @@ -15,15 +15,25 @@ "build": { "builder": "@angular-devkit/build-angular:browser", "options": { - "aot": true, "outputPath": "dist/apps/example-app", "index": "apps/example-app/src/index.html", "main": "apps/example-app/src/main.ts", "polyfills": "apps/example-app/src/polyfills.ts", "tsConfig": "apps/example-app/tsconfig.app.json", - "assets": ["apps/example-app/src/favicon.ico", "apps/example-app/src/assets"], - "styles": ["apps/example-app/src/styles.css"], - "scripts": [] + "assets": [ + "apps/example-app/src/favicon.ico", + "apps/example-app/src/assets" + ], + "styles": [ + "apps/example-app/src/styles.css" + ], + "scripts": [], + "vendorChunk": true, + "extractLicenses": false, + "buildOptimizer": false, + "sourceMap": true, + "optimization": false, + "namedChunks": true }, "configurations": { "production": { @@ -43,13 +53,14 @@ "outputHashing": "all", "sourceMap": false, "namedChunks": false, - "aot": true, "extractLicenses": true, "vendorChunk": false, "buildOptimizer": true } }, - "outputs": ["{options.outputPath}"] + "outputs": [ + "{options.outputPath}" + ] }, "serve": { "builder": "@angular-devkit/build-angular:dev-server", @@ -71,7 +82,13 @@ "lint": { "builder": "@nrwl/linter:eslint", "options": { - "lintFilePatterns": ["apps/example-app/src/**/*.ts", "apps/example-app/src/**/*.html"] + "lintFilePatterns": [ + "apps/example-app/**/*.ts", + "apps/example-app/**/*.html", + "apps/example-app/src/**/*.html", + "apps/example-app/src/**/*.html", + "apps/example-app/src/**/*.html" + ] } }, "test": { @@ -80,7 +97,9 @@ "jestConfig": "apps/example-app/jest.config.js", "setupFile": "apps/example-app/src/test-setup.ts" }, - "outputs": ["coverage/"] + "outputs": [ + "coverage/" + ] } } }, @@ -107,7 +126,9 @@ "builder": "@nrwl/linter:eslint", "options": { "lintFilePatterns": [ - "projects/testing-library/src/**/*.ts", + "projects/testing-library/**/*.ts", + "projects/testing-library/**/*.html", + "projects/testing-library/src/**/*.html", "projects/testing-library/src/**/*.html", "projects/testing-library/src/**/*.html" ] @@ -133,7 +154,9 @@ "jestConfig": "projects/testing-library/jest.config.js", "setupFile": "projects/testing-library/test-setup.ts" }, - "outputs": ["coverage/projects/testing-library"] + "outputs": [ + "coverage/projects/testing-library" + ] } } }, @@ -160,7 +183,9 @@ "builder": "@nrwl/linter:eslint", "options": { "lintFilePatterns": [ - "projects/jest-utils/src/**/*.ts", + "projects/jest-utils/**/*.ts", + "projects/jest-utils/**/*.html", + "projects/jest-utils/src/**/*.html", "projects/jest-utils/src/**/*.html", "projects/jest-utils/src/**/*.html" ] @@ -183,9 +208,11 @@ "jestConfig": "projects/jest-utils/jest.config.js", "setupFile": "projects/jest-utils/test-setup.ts" }, - "outputs": ["coverage/projects/jest-utils"] + "outputs": [ + "coverage/projects/jest-utils" + ] } } } } -} +} \ No newline at end of file diff --git a/apps/example-app/.eslintrc.json b/apps/example-app/.eslintrc.json index 2e1ae78b..9f90c874 100644 --- a/apps/example-app/.eslintrc.json +++ b/apps/example-app/.eslintrc.json @@ -1,5 +1,5 @@ { - "extends": ["../../.eslintrc.json"], + "extends": "../../.eslintrc.json", "ignorePatterns": ["!**/*"], "overrides": [ { @@ -25,8 +25,7 @@ "style": "kebab-case" } ] - }, - "plugins": ["@angular-eslint/eslint-plugin", "@typescript-eslint"] + } }, { "files": ["*.html"], diff --git a/apps/example-app/src/app/examples/09-router.ts b/apps/example-app/src/app/examples/09-router.ts index 035124c8..7d4e300d 100644 --- a/apps/example-app/src/app/examples/09-router.ts +++ b/apps/example-app/src/app/examples/09-router.ts @@ -3,7 +3,7 @@ import { ActivatedRoute } from '@angular/router'; import { map } from 'rxjs/operators'; @Component({ - selector: 'app-master', + selector: 'app-main', template: ` Load one | Load two | Load three | diff --git a/apps/example-app/src/app/issues/issue-106.spec.ts b/apps/example-app/src/app/issues/issue-106.spec.ts index 52bc81e1..0ac749a8 100644 --- a/apps/example-app/src/app/issues/issue-106.spec.ts +++ b/apps/example-app/src/app/issues/issue-106.spec.ts @@ -6,7 +6,7 @@ import { render, screen, fireEvent, waitFor } from '@testing-library/angular'; template: `
Here I am
`, }) -export class TestSelectComponent { +class TestSelectComponent { showSubj = new BehaviorSubject(false); show$ = this.showSubj.asObservable(); diff --git a/apps/example-app/src/environments/environment.ts b/apps/example-app/src/environments/environment.ts index 665463cc..85db3caf 100644 --- a/apps/example-app/src/environments/environment.ts +++ b/apps/example-app/src/environments/environment.ts @@ -12,4 +12,4 @@ export const environment = { * import the following file, but please comment it out in production mode * because it will have performance impact when throw error */ -// import 'zone.js/dist/zone-error'; // Included with Angular CLI. +// import 'zone.js/plugins/zone-error'; // Included with Angular CLI. diff --git a/apps/example-app/src/polyfills.ts b/apps/example-app/src/polyfills.ts index 1348d74b..bb20fec0 100644 --- a/apps/example-app/src/polyfills.ts +++ b/apps/example-app/src/polyfills.ts @@ -68,7 +68,7 @@ /** ************************************************************************************************* * Zone JS is required by default for Angular itself. */ -import 'zone.js/dist/zone'; // Included with Angular CLI. +import 'zone.js'; // Included with Angular CLI. /** ************************************************************************************************* * APPLICATION IMPORTS diff --git a/nx.json b/nx.json index c99139c8..132d0c91 100644 --- a/nx.json +++ b/nx.json @@ -10,7 +10,7 @@ "nx.json": "*" }, "affected": { - "defaultBase": "master" + "defaultBase": "main" }, "npmScope": "testing-library", "tasksRunnerOptions": { diff --git a/package.json b/package.json index 0490d1c6..d9a00217 100644 --- a/package.json +++ b/package.json @@ -25,17 +25,17 @@ "semantic-release": "semantic-release" }, "dependencies": { - "@angular/animations": "11.2.9", - "@angular/cdk": "11.2.9", - "@angular/common": "11.2.9", - "@angular/compiler": "11.2.9", - "@angular/core": "11.2.9", - "@angular/forms": "11.2.9", - "@angular/material": "11.2.9", - "@angular/platform-browser": "11.2.9", - "@angular/platform-browser-dynamic": "11.2.9", - "@angular/router": "11.2.9", - "@ngrx/store": "11.0.0", + "@angular/animations": "12.0.0", + "@angular/cdk": "12.0.0", + "@angular/common": "12.0.0", + "@angular/compiler": "12.0.0", + "@angular/core": "12.0.0", + "@angular/forms": "12.0.0", + "@angular/material": "12.0.0", + "@angular/platform-browser": "12.0.0", + "@angular/platform-browser-dynamic": "12.0.0", + "@angular/router": "12.0.0", + "@ngrx/store": "12.0.0", "@nrwl/angular": "12.0.3", "@nrwl/nx-cloud": "11.2.0", "@testing-library/dom": "7.29.4", @@ -46,41 +46,42 @@ "zone.js": "~0.11.4" }, "devDependencies": { - "@angular-devkit/build-angular": "0.1102.8", + "@angular-devkit/build-angular": "12.0.0", "@angular-eslint/eslint-plugin": "~2.1.0", "@angular-eslint/eslint-plugin-template": "~2.1.0", "@angular-eslint/template-parser": "~2.1.0", - "@angular/cli": "11.2.8", - "@angular/compiler-cli": "11.2.9", - "@angular/language-service": "11.2.9", + "@angular/cli": "12.0.0", + "@angular/compiler-cli": "12.0.0", + "@angular/language-service": "12.0.0", "@nrwl/cli": "12.0.3", "@nrwl/eslint-plugin-nx": "12.0.3", "@nrwl/jest": "12.0.3", "@nrwl/linter": "12.0.3", "@nrwl/node": "12.0.3", "@nrwl/nx-plugin": "12.0.3", - "@nrwl/workspace": "12.0.3", + "@nrwl/workspace": "12.3.1", "@testing-library/jest-dom": "^5.11.10", "@types/jest": "~26.0.3", "@types/node": "14.14.37", "@typescript-eslint/eslint-plugin": "4.22.0", "@typescript-eslint/parser": "4.22.0", "cpy-cli": "^3.1.1", - "eslint": "7.24.0", + "eslint": "^7.25.0", "eslint-config-prettier": "8.2.0", "eslint-plugin-import": "latest", + "eslint-plugin-jest": "^24.3.5", "eslint-plugin-jest-dom": "3.8.0", "eslint-plugin-testing-library": "^4.0.1", "husky": "^4.2.5", "jest": "^26.1.0", "jest-preset-angular": "8.4.0", "lint-staged": "^10.2.11", - "ng-packagr": "11.2.4", + "ng-packagr": "12.0.0", "prettier": "2.2.1", "rimraf": "^3.0.2", "semantic-release": "^17.1.1", "ts-jest": "26.5.4", "ts-node": "9.1.1", - "typescript": "4.1.4" + "typescript": "4.2.4" } -} +} \ No newline at end of file diff --git a/projects/jest-utils/.eslintrc.json b/projects/jest-utils/.eslintrc.json index 4687290e..90906e5b 100644 --- a/projects/jest-utils/.eslintrc.json +++ b/projects/jest-utils/.eslintrc.json @@ -13,7 +13,7 @@ "error", { "type": "attribute", - "prefix": "lib", + "prefix": "atl", "style": "camelCase" } ], @@ -21,7 +21,7 @@ "error", { "type": "element", - "prefix": "lib", + "prefix": "atl", "style": "kebab-case" } ] diff --git a/projects/jest-utils/tests/create-mock.spec.ts b/projects/jest-utils/tests/create-mock.spec.ts index 9494f8cb..8b814fe6 100644 --- a/projects/jest-utils/tests/create-mock.spec.ts +++ b/projects/jest-utils/tests/create-mock.spec.ts @@ -1,8 +1,8 @@ import { Component } from '@angular/core'; import { TestBed } from '@angular/core/testing'; +import { fireEvent, render } from '@testing-library/angular'; import { createMock, provideMock, Mock } from '../src/public_api'; -import { render, fireEvent } from '../../testing-library/src/public_api'; class FixtureService { constructor(private foo: string, public bar: string) {} @@ -13,10 +13,10 @@ class FixtureService { } @Component({ - selector: 'fixture', + selector: 'atl-fixture', template: ` `, }) -export class FixtureComponent { +class FixtureComponent { constructor(private service: FixtureService) {} print() { @@ -39,6 +39,7 @@ it('provides a mock service', async () => { expect(service.print).toHaveBeenCalledTimes(1); }); +// eslint-disable-next-line jest/expect-expect it('is possible to write a mock implementation', async (done) => { const { getByText } = await render(FixtureComponent, { providers: [provideMock(FixtureService)], diff --git a/projects/testing-library/.eslintrc.json b/projects/testing-library/.eslintrc.json index f3960e87..4ad0bed8 100644 --- a/projects/testing-library/.eslintrc.json +++ b/projects/testing-library/.eslintrc.json @@ -13,7 +13,7 @@ "error", { "type": "attribute", - "prefix": "lib", + "prefix": "atl", "style": "camelCase" } ], @@ -21,7 +21,7 @@ "error", { "type": "element", - "prefix": "lib", + "prefix": "atl", "style": "kebab-case" } ] diff --git a/projects/testing-library/package.json b/projects/testing-library/package.json index 7fb78fff..29bd7073 100644 --- a/projects/testing-library/package.json +++ b/projects/testing-library/package.json @@ -22,11 +22,11 @@ }, "homepage": "https://github.com/testing-library/angular-testing-library#readme", "peerDependencies": { - "@angular/common": ">= 10.0.0 < 12", - "@angular/platform-browser": ">= 10.0.0 < 12", - "@angular/animations": ">= 10.0.0 < 12", - "@angular/router": ">= 10.0.0 < 12", - "@angular/core": ">= 10.0.0 < 12" + "@angular/common": ">= 10.0.0", + "@angular/platform-browser": ">= 10.0.0", + "@angular/animations": ">= 10.0.0", + "@angular/router": ">= 10.0.0", + "@angular/core": ">= 10.0.0" }, "dependencies": { "@testing-library/dom": "7.29.4", diff --git a/projects/testing-library/src/lib/testing-library.ts b/projects/testing-library/src/lib/testing-library.ts index fe3a22ca..3c3b86f7 100644 --- a/projects/testing-library/src/lib/testing-library.ts +++ b/projects/testing-library/src/lib/testing-library.ts @@ -358,6 +358,7 @@ if (typeof afterEach === 'function' && !process.env.ATL_SKIP_AUTO_CLEANUP) { }); } +// TODO: rename to `atl-wrapper-component` // eslint-disable-next-line @angular-eslint/component-selector @Component({ selector: 'wrapper-component', template: '' }) class WrapperComponent {} @@ -370,7 +371,7 @@ function replaceFindWithFindAndDetectChanges(originalQueriesForContainer: T): const getByQuery = originalQueriesForContainer[key.replace('find', 'get')]; if (key.startsWith('find') && getByQuery) { newQueries[key] = async (text, options, waitOptions) => { - // original implementation at https://github.com/testing-library/dom-testing-library/blob/master/src/query-helpers.js + // original implementation at https://github.com/testing-library/dom-testing-library/blob/main/src/query-helpers.js const result = await waitForWrapper( detectChangesForMountedFixtures, () => getByQuery(text, options), diff --git a/projects/testing-library/tests/auto-cleanup.spec.ts b/projects/testing-library/tests/auto-cleanup.spec.ts index 13f0de8c..a22b646c 100644 --- a/projects/testing-library/tests/auto-cleanup.spec.ts +++ b/projects/testing-library/tests/auto-cleanup.spec.ts @@ -2,8 +2,8 @@ import { Component, Input } from '@angular/core'; import { render } from '../src/public_api'; @Component({ - selector: 'fixture', - template: ` Hello {{ name }}! `, + selector: 'atl-fixture', + template: `Hello {{ name }}!`, }) class FixtureComponent { @Input() name: string; diff --git a/projects/testing-library/tests/config.spec.ts b/projects/testing-library/tests/config.spec.ts index 06a79915..ccd004f5 100644 --- a/projects/testing-library/tests/config.spec.ts +++ b/projects/testing-library/tests/config.spec.ts @@ -4,7 +4,7 @@ import { render, configure } from '../src/public_api'; import { ReactiveFormsModule, FormBuilder } from '@angular/forms'; @Component({ - selector: 'app-fixture', + selector: 'atl-fixture', template: `
diff --git a/projects/testing-library/tests/debug.spec.ts b/projects/testing-library/tests/debug.spec.ts index 3a868989..29845d3b 100644 --- a/projects/testing-library/tests/debug.spec.ts +++ b/projects/testing-library/tests/debug.spec.ts @@ -2,7 +2,7 @@ import { Component } from '@angular/core'; import { render } from '../src/public_api'; @Component({ - selector: 'fixture', + selector: 'atl-fixture', template: `

rawr

@@ -11,7 +11,7 @@ import { render } from '../src/public_api'; class FixtureComponent {} test('debug', async () => { - jest.spyOn(console, 'log').mockImplementation(() => {}); + jest.spyOn(console, 'log').mockImplementation(); const { debug } = await render(FixtureComponent); debug(); @@ -21,7 +21,7 @@ test('debug', async () => { }); test('debug allows to be called with an element', async () => { - jest.spyOn(console, 'log').mockImplementation(() => {}); + jest.spyOn(console, 'log').mockImplementation(); const { debug, getByTestId } = await render(FixtureComponent); const btn = getByTestId('btn'); diff --git a/projects/testing-library/tests/detect-changes.spec.ts b/projects/testing-library/tests/detect-changes.spec.ts index e74c402f..5dae8254 100644 --- a/projects/testing-library/tests/detect-changes.spec.ts +++ b/projects/testing-library/tests/detect-changes.spec.ts @@ -5,7 +5,7 @@ import { delay } from 'rxjs/operators'; import { render, fireEvent } from '../src/public_api'; @Component({ - selector: 'fixture', + selector: 'atl-fixture', template: ` diff --git a/projects/testing-library/tests/find-by.spec.ts b/projects/testing-library/tests/find-by.spec.ts index 791fa215..c55430ee 100644 --- a/projects/testing-library/tests/find-by.spec.ts +++ b/projects/testing-library/tests/find-by.spec.ts @@ -4,7 +4,7 @@ import { render, screen } from '../src/public_api'; import { mapTo } from 'rxjs/operators'; @Component({ - selector: 'fixture', + selector: 'atl-fixture', template: `
{{ result | async }}
`, }) class FixtureComponent { diff --git a/projects/testing-library/tests/fire-event.spec.ts b/projects/testing-library/tests/fire-event.spec.ts index 1c93bc59..7a9a7f0d 100644 --- a/projects/testing-library/tests/fire-event.spec.ts +++ b/projects/testing-library/tests/fire-event.spec.ts @@ -2,7 +2,7 @@ import { Component } from '@angular/core'; import { render, fireEvent } from '../src/public_api'; @Component({ - selector: 'fixture', + selector: 'atl-fixture', template: ` `, }) class FixtureComponent {} diff --git a/projects/testing-library/tests/issues/188.spec.ts b/projects/testing-library/tests/issues/188.spec.ts index c972aad0..cb430bb4 100644 --- a/projects/testing-library/tests/issues/188.spec.ts +++ b/projects/testing-library/tests/issues/188.spec.ts @@ -5,7 +5,7 @@ import { render } from '../../src/public_api'; @Component({ template: `

Hello {{ formattedName }}

`, }) -export class BugOnChangeComponent implements OnChanges { +class BugOnChangeComponent implements OnChanges { @Input() name: string; formattedName: string; diff --git a/projects/testing-library/tests/issues/67.spec.ts b/projects/testing-library/tests/issues/67.spec.ts index 1e4dff75..243dbf4d 100644 --- a/projects/testing-library/tests/issues/67.spec.ts +++ b/projects/testing-library/tests/issues/67.spec.ts @@ -13,7 +13,7 @@ import { render } from '../../src/public_api';
`, }) -export class BugGetByLabelTextComponent {} +class BugGetByLabelTextComponent {} it('first step to reproduce the bug: skip this test to avoid the error or remove the for attribute of label', async () => { expect(await render(BugGetByLabelTextComponent)).toBeDefined(); diff --git a/projects/testing-library/tests/navigate.spec.ts b/projects/testing-library/tests/navigate.spec.ts index d26dde3b..ca0d8ad8 100644 --- a/projects/testing-library/tests/navigate.spec.ts +++ b/projects/testing-library/tests/navigate.spec.ts @@ -4,7 +4,7 @@ import { Router } from '@angular/router'; import { render } from '../src/public_api'; @Component({ - selector: 'fixture', + selector: 'atl-fixture', template: ``, }) class FixtureComponent {} diff --git a/projects/testing-library/tests/providers/component-provider.spec.ts b/projects/testing-library/tests/providers/component-provider.spec.ts index e7c88c8a..723a0317 100644 --- a/projects/testing-library/tests/providers/component-provider.spec.ts +++ b/projects/testing-library/tests/providers/component-provider.spec.ts @@ -43,17 +43,17 @@ test('shows the provided service value with template syntax', async () => { }); @Injectable() -export class Service { +class Service { foo() { return 'foo'; } } @Component({ - selector: 'fixture-component', + selector: 'atl-fixture', template: '{{service.foo()}}', providers: [Service], }) -export class FixtureComponent { +class FixtureComponent { constructor(public service: Service) {} } diff --git a/projects/testing-library/tests/providers/module-provider.spec.ts b/projects/testing-library/tests/providers/module-provider.spec.ts index 6270795f..82dbee64 100644 --- a/projects/testing-library/tests/providers/module-provider.spec.ts +++ b/projects/testing-library/tests/providers/module-provider.spec.ts @@ -53,16 +53,16 @@ test('shows the provided service value with template syntax', async () => { }); @Injectable() -export class Service { +class Service { foo() { return 'foo'; } } @Component({ - selector: 'fixture-component', + selector: 'atl-fixture', template: '{{service.foo()}}', }) -export class FixtureComponent { +class FixtureComponent { constructor(public service: Service) {} } diff --git a/projects/testing-library/tests/render-template.spec.ts b/projects/testing-library/tests/render-template.spec.ts index 1bc4e30d..73420211 100644 --- a/projects/testing-library/tests/render-template.spec.ts +++ b/projects/testing-library/tests/render-template.spec.ts @@ -1,5 +1,3 @@ -/* eslint-disable testing-library/no-container */ -/* eslint-disable testing-library/render-result-naming-convention */ import { Directive, HostListener, ElementRef, Input, Output, EventEmitter, Component } from '@angular/core'; import { render, fireEvent } from '../src/public_api'; @@ -8,7 +6,7 @@ import { render, fireEvent } from '../src/public_api'; // eslint-disable-next-line @angular-eslint/directive-selector selector: '[onOff]', }) -export class OnOffDirective { +class OnOffDirective { @Input() on = 'on'; @Input() off = 'off'; @Output() clicked = new EventEmitter(); @@ -27,7 +25,7 @@ export class OnOffDirective { // eslint-disable-next-line @angular-eslint/directive-selector selector: '[update]', }) -export class UpdateInputDirective { +class UpdateInputDirective { @Input() set update(value: any) { this.el.nativeElement.textContent = value; @@ -41,7 +39,7 @@ export class UpdateInputDirective { selector: 'greeting', template: 'Hello {{ name }}!', }) -export class GreetingComponent { +class GreetingComponent { @Input() name = 'World'; } @@ -59,7 +57,7 @@ test('the component renders', async () => { }); expect(component.container.querySelector('greeting')).toBeInTheDocument(); - expect(component.getByText('Hello Angular!')); + expect(component.getByText('Hello Angular!')).toBeInTheDocument(); }); test('the directive renders (compatibility with the deprecated signature)', async () => { @@ -70,7 +68,7 @@ test('the directive renders (compatibility with the deprecated signature)', asyn expect(component.container.querySelector('[onoff]')).toBeInTheDocument(); }); -test.only('uses the default props', async () => { +test('uses the default props', async () => { const component = await render('
', { declarations: [OnOffDirective], }); diff --git a/projects/testing-library/tests/render.spec.ts b/projects/testing-library/tests/render.spec.ts index 01fe9f0c..aeac9789 100644 --- a/projects/testing-library/tests/render.spec.ts +++ b/projects/testing-library/tests/render.spec.ts @@ -13,7 +13,7 @@ import { TestBed } from '@angular/core/testing'; import { render, fireEvent } from '../src/public_api'; @Component({ - selector: 'fixture', + selector: 'atl-fixture', template: ` @@ -83,7 +83,7 @@ describe('animationModule', () => { describe('Angular component life-cycle hooks', () => { @Component({ - selector: 'fixture', + selector: 'atl-fixture', template: ` {{ name }} `, }) class FixtureWithNgOnChangesComponent implements OnInit, OnChanges { diff --git a/projects/testing-library/tests/rerender.spec.ts b/projects/testing-library/tests/rerender.spec.ts index 5f7d152a..f9f82ca0 100644 --- a/projects/testing-library/tests/rerender.spec.ts +++ b/projects/testing-library/tests/rerender.spec.ts @@ -3,7 +3,7 @@ import { screen } from '@testing-library/dom'; import { render } from '../src/public_api'; @Component({ - selector: 'fixture', + selector: 'atl-fixture', template: ` {{ name }} `, }) class FixtureComponent { @@ -23,7 +23,7 @@ test('will rerender the component with updated props', async () => { }); @Component({ - selector: 'fixture-onchanges', + selector: 'atl-fixture', template: ` {{ name }} `, }) class FixtureWithNgOnChangesComponent implements OnChanges { @@ -54,7 +54,7 @@ test('will call ngOnChanges on rerender', async () => { @Component({ changeDetection: ChangeDetectionStrategy.OnPush, - selector: 'fixture-onpush', + selector: 'atl-fixture', template: `
Number
`, }) class FixtureWithOnPushComponent { diff --git a/projects/testing-library/tests/wait-for-element-to-be-removed.spec.ts b/projects/testing-library/tests/wait-for-element-to-be-removed.spec.ts index c3859c62..0995c8ca 100644 --- a/projects/testing-library/tests/wait-for-element-to-be-removed.spec.ts +++ b/projects/testing-library/tests/wait-for-element-to-be-removed.spec.ts @@ -3,7 +3,7 @@ import { render, screen, waitForElementToBeRemoved } from '../src/public_api'; import { timer } from 'rxjs'; @Component({ - selector: 'fixture', + selector: 'atl-fixture', template: `
👋
`, }) class FixtureComponent implements OnInit { diff --git a/projects/testing-library/tests/wait-for.spec.ts b/projects/testing-library/tests/wait-for.spec.ts index 082358be..ce80b08d 100644 --- a/projects/testing-library/tests/wait-for.spec.ts +++ b/projects/testing-library/tests/wait-for.spec.ts @@ -3,7 +3,7 @@ import { timer } from 'rxjs'; import { render, screen, fireEvent, waitFor as waitForATL } from '../src/public_api'; @Component({ - selector: 'fixture', + selector: 'atl-fixture', template: `
{{ result }}
diff --git a/release.config.js b/release.config.js index 9c0c79a3..3bf46c17 100644 --- a/release.config.js +++ b/release.config.js @@ -1,4 +1,4 @@ module.exports = { pkgRoot: 'dist/@testing-library/angular', - branches: ['master', { name: 'beta', prerelease: true }], + branches: ['main', { name: 'beta', prerelease: true }], };