Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
246 changes: 54 additions & 192 deletions .all-contributorsrc

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// For format details, see https://aka.ms/devcontainer.json.
{
"name": "angular-testing-library",
"image": "mcr.microsoft.com/devcontainers/typescript-node:22-bullseye",
"image": "mcr.microsoft.com/devcontainers/typescript-node:24-bookworm",

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,4 @@ yarn.lock
# System Files
.DS_Store
Thumbs.db
.cursor/rules/nx-rules.mdc
.github/instructions/nx.instructions.md
.history
1 change: 0 additions & 1 deletion .nxignore

This file was deleted.

15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ practices.</p>
- [Table of Contents](#table-of-contents)
- [The problem](#the-problem)
- [This solution](#this-solution)
- [Zoneless support](#zoneless-support)
- [Example](#example)
- [Installation](#installation)
- [Version compatibility](#version-compatibility)
Expand Down Expand Up @@ -92,6 +93,20 @@ primary guiding principle is:
> [The more your tests resemble the way your software is used, the more
> confidence they can give you.][guiding-principle]

## Zoneless support

For zoneless applications, Angular Testing Library provides a dedicated slim entry point:

```ts
import { render } from '@testing-library/angular/zoneless';
```

A schematic is available to migrate existing tests:

```bash
ng generate @testing-library/angular:migrate-to-zoneless
```

## Example

counter.component.ts
Expand Down
134 changes: 5 additions & 129 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,53 +61,17 @@
"sourceRoot": "apps/example-app/src",
"prefix": "app",
"architect": {
"build": {
"test-build": {
"builder": "@angular/build:application",
"options": {
"outputPath": {
"base": "dist/apps/example-app"
},
"index": "apps/example-app/src/index.html",
"tsConfig": "apps/example-app/tsconfig.app.json",
"assets": ["apps/example-app/src/favicon.ico", "apps/example-app/src/assets"],
"styles": [],
"scripts": [],
"browser": "apps/example-app/src/main.ts"
},
"configurations": {
"production": {
"budgets": [
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular/build:dev-server",
"configurations": {
"production": {
"buildTarget": "example-app:build:production"
},
"development": {
"buildTarget": "example-app:build:development"
}
},
"defaultConfiguration": "development"
"polyfills": [],
"tsConfig": "apps/example-app/tsconfig.spec.json"
}
},
"test": {
"builder": "@angular/build:unit-test",
"options": {
"buildTarget": "example-app:test-build",
"setupFiles": ["apps/example-app/test-setup.ts"]
}
},
Expand All @@ -125,50 +89,6 @@
"sourceRoot": "apps/example-app-jest/src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular/build:application",
"options": {
"outputPath": {
"base": "dist/apps/example-app-jest"
},
"index": "apps/example-app-jest/src/index.html",
"tsConfig": "apps/example-app-jest/tsconfig.app.json",
"assets": ["apps/example-app-jest/src/favicon.ico", "apps/example-app-jest/src/assets"],
"styles": [],
"scripts": [],
"browser": "apps/example-app-jest/src/main.ts"
},
"configurations": {
"production": {
"budgets": [
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular/build:dev-server",
"configurations": {
"production": {
"buildTarget": "example-app-jest:build:production"
},
"development": {
"buildTarget": "example-app-jest:build:development"
}
},
"defaultConfiguration": "development"
},
"test": {
"builder": "@angular-builders/jest:run",
"options": {
Expand All @@ -189,50 +109,6 @@
"sourceRoot": "apps/example-app-karma/src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular/build:application",
"options": {
"outputPath": {
"base": "dist/apps/example-app-karma"
},
"index": "apps/example-app-karma/src/index.html",
"tsConfig": "apps/example-app-karma/tsconfig.app.json",
"assets": ["apps/example-app-karma/src/favicon.ico", "apps/example-app-karma/src/assets"],
"styles": [],
"scripts": [],
"browser": "apps/example-app-karma/src/main.ts"
},
"configurations": {
"production": {
"budgets": [
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular/build:dev-server",
"configurations": {
"production": {
"buildTarget": "example-app-karma:build:production"
},
"development": {
"buildTarget": "example-app-karma:build:development"
}
},
"defaultConfiguration": "development"
},
"test": {
"builder": "@angular/build:karma",
"options": {
Expand Down
7 changes: 0 additions & 7 deletions apps/example-app-jest/eslint.config.cjs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export class DeferableViewChildComponent {}
@Component({
template: `
@defer (on timer(2s)) {
<atl-deferable-view-child />
<atl-deferable-view-child />
} @placeholder {
<p>Hello from placeholder</p>
<p>Hello from placeholder</p>
} @loading {
<p>Hello from loading</p>
<p>Hello from loading</p>
} @error {
<p>Hello from error</p>
<p>Hello from error</p>
}
`,
imports: [DeferableViewChildComponent],
Expand Down
21 changes: 0 additions & 21 deletions apps/example-app-jest/tsconfig.app.json

This file was deleted.

3 changes: 0 additions & 3 deletions apps/example-app-jest/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
"strictTemplates": true
},
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.spec.json"
}
Expand Down
7 changes: 0 additions & 7 deletions apps/example-app-karma/eslint.config.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion apps/example-app-karma/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = function (config) {
try {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
frameworks: ['jasmine'],
plugins: [require('karma-jasmine'), require('karma-chrome-launcher')],
client: {
jasmine: {
Expand Down
4 changes: 2 additions & 2 deletions apps/example-app-karma/src/app/examples/login-form.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ it('should display invalid message and submit button must be disabled', async ()
<form [formGroup]="form" (submit)="onSubmit(form)">
<input type="email" aria-label="email" formControlName="email" />
@if (email.invalid && (email.dirty || email.touched)) {
<div role="alert">Email is invalid</div>
<div role="alert">Email is invalid</div>
}
<input type="password" aria-label="password" formControlName="password" />
@if (password.invalid && (password.dirty || password.touched)) {
<div role="alert">Password is invalid</div>
<div role="alert">Password is invalid</div>
}
<button type="submit" aria-label="submit" [disabled]="form.invalid">Submit</button>
</form>
Expand Down
21 changes: 0 additions & 21 deletions apps/example-app-karma/tsconfig.app.json

This file was deleted.

3 changes: 0 additions & 3 deletions apps/example-app-karma/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
"strictTemplates": true
},
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.spec.json"
}
Expand Down
7 changes: 0 additions & 7 deletions apps/example-app/eslint.config.cjs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export class DeferableViewChildComponent {}
@Component({
template: `
@defer (on timer(2s)) {
<atl-deferable-view-child />
<atl-deferable-view-child />
} @placeholder {
<p>Hello from placeholder</p>
<p>Hello from placeholder</p>
} @loading {
<p>Hello from loading</p>
<p>Hello from loading</p>
} @error {
<p>Hello from error</p>
<p>Hello from error</p>
}
`,
imports: [DeferableViewChildComponent],
Expand Down
21 changes: 0 additions & 21 deletions apps/example-app/tsconfig.app.json

This file was deleted.

3 changes: 0 additions & 3 deletions apps/example-app/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
"strictTemplates": true
},
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.spec.json"
}
Expand Down
7 changes: 0 additions & 7 deletions eslint.config.cjs

This file was deleted.

Loading