Skip to content

Commit acc747f

Browse files
feat: add zone subpackage (#599)
1 parent e6f4e26 commit acc747f

6 files changed

Lines changed: 51 additions & 2 deletions

File tree

‎angular.json‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@
4444
"options": {
4545
"buildTarget": "testing-library:test-build-zoneless",
4646
"setupFiles": ["projects/testing-library/test-setup.ts"],
47-
"include": ["**/*.spec.ts", "../zoneless/**/*.spec.ts", "../schematics/**/*.spec.ts"]
47+
"include": [
48+
"**/*.spec.ts",
49+
"../zone/**/*.spec.ts",
50+
"../zoneless/**/*.spec.ts",
51+
"../schematics/**/*.spec.ts"
52+
]
4853
}
4954
},
5055
"lint": {

‎projects/testing-library/tsconfig.spec.json‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
"compilerOptions": {
44
"types": ["node"],
55
"target": "ES2022",
6-
"useDefineForClassFields": false
6+
"useDefineForClassFields": false,
7+
"paths": {
8+
"@testing-library/angular": ["./index.ts"]
9+
}
710
},
811
"include": ["**/*.ts"]
912
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './src/public_api';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
* Public API Surface of @testing-library/angular/zone
3+
*
4+
* This entry point re-exports the zone-based API of `@testing-library/angular`.
5+
* It exists so codebases can explicitly opt in to the zone-based `render`,
6+
* ahead of `@testing-library/angular/zoneless` becoming the default.
7+
*/
8+
9+
export * from '@testing-library/angular';
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Component } from '@angular/core';
2+
import { test, expect } from 'vitest';
3+
import * as root from '../../index';
4+
import * as zone from '../index';
5+
import { render, screen } from '../index';
6+
7+
test('re-exports the same public API as @testing-library/angular', () => {
8+
const rootExports = root as Record<string, unknown>;
9+
const zoneExports = zone as Record<string, unknown>;
10+
11+
expect(Object.keys(zoneExports).sort()).toEqual(Object.keys(rootExports).sort());
12+
13+
for (const key of Object.keys(rootExports)) {
14+
expect(zoneExports[key]).toBe(rootExports[key]);
15+
}
16+
});
17+
18+
@Component({
19+
selector: 'atl-fixture',
20+
template: `<span>Hello {{ name }}</span>`,
21+
})
22+
class FixtureComponent {
23+
name = 'world';
24+
}
25+
26+
test('renders a component', async () => {
27+
await render(FixtureComponent);
28+
29+
expect(screen.getByText('Hello world')).toBeInTheDocument();
30+
});

0 commit comments

Comments
 (0)