-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support config zoneless env for CJS
- Loading branch information
Showing
23 changed files
with
365 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { FooComponent } from '../foo.component'; | ||
|
||
describe('FooComponent', () => { | ||
it('should trigger change detection without fixture.detectChanges', () => { | ||
TestBed.configureTestingModule({ | ||
imports: [FooComponent], | ||
}); | ||
const fixture = TestBed.createComponent(FooComponent); | ||
|
||
expect(fixture.componentInstance.value1()).toBe('val1'); | ||
|
||
fixture.componentRef.setInput('value1', 'hello'); | ||
|
||
expect(fixture.componentInstance.value1()).toBe('hello'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!-- SOMETHING --> | ||
<p>Line 1</p> | ||
<div> | ||
<div *ngIf="condition1"> | ||
{{ value1() }} | ||
</div> | ||
<span *ngIf="condition2"> | ||
{{ value2() }} | ||
</span> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
p { | ||
font-size: 1.6rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { NgIf } from '@angular/common'; | ||
import { Component, input } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'foo', | ||
standalone: true, | ||
templateUrl: './foo.component.html', | ||
styleUrls: ['./foo.component.scss'], | ||
// we have to setup styles this way, since simple styles/styleUrs properties will be removed (jest does not unit test styles) | ||
styles: [ | ||
` | ||
p { | ||
color: red; | ||
} | ||
`, | ||
], | ||
imports: [NgIf], | ||
}) | ||
export class FooComponent { | ||
readonly value1 = input('val1'); | ||
readonly value2 = input('val2'); | ||
|
||
protected readonly condition1 = true; | ||
protected readonly condition2 = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { JestConfigWithTsJest } from 'ts-jest'; | ||
|
||
const config: JestConfigWithTsJest = { | ||
displayName: 'e2e-zoneless-env', | ||
testEnvironment: 'jsdom', | ||
snapshotSerializers: [ | ||
'<rootDir>/../../build/serializers/html-comment', | ||
'<rootDir>/../../build/serializers/ng-snapshot', | ||
'<rootDir>/../../build/serializers/no-ng-attributes', | ||
], | ||
setupFilesAfterEnv: ['./setup-zoneless-env.ts'], | ||
transform: { | ||
'^.+\\.(ts|js|mjs|html)$': [ | ||
'<rootDir>/../../build/index.js', | ||
{ | ||
tsconfig: '<rootDir>/tsconfig-cjs.spec.json', | ||
stringifyContentPathRegex: '\\.(html|svg)$', | ||
}, | ||
], | ||
}, | ||
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'], | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { JestConfigWithTsJest } from 'ts-jest'; | ||
|
||
const config: JestConfigWithTsJest = { | ||
displayName: 'e2e-zoneless-env', | ||
testEnvironment: 'jsdom', | ||
snapshotSerializers: [ | ||
'<rootDir>/../../build/serializers/html-comment', | ||
'<rootDir>/../../build/serializers/ng-snapshot', | ||
'<rootDir>/../../build/serializers/no-ng-attributes', | ||
], | ||
setupFilesAfterEnv: ['./setup-zoneless-env.mts'], | ||
moduleNameMapper: { | ||
rxjs: '<rootDir>/../../node_modules/rxjs/dist/bundles/rxjs.umd.js', | ||
}, | ||
extensionsToTreatAsEsm: ['.ts', '.mts'], | ||
transform: { | ||
'^.+\\.(ts|mts|js|mjs|html)$': [ | ||
'<rootDir>/../../build/index.js', | ||
{ | ||
useESM: true, | ||
tsconfig: '<rootDir>/tsconfig-esm.spec.json', | ||
stringifyContentPathRegex: '\\.(html|svg)$', | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { JestConfigWithTsJest } from 'ts-jest'; | ||
|
||
const config: JestConfigWithTsJest = { | ||
displayName: 'e2e-snapshot-serializers', | ||
testEnvironment: 'jsdom', | ||
snapshotSerializers: [ | ||
'<rootDir>/../../build/serializers/html-comment', | ||
'<rootDir>/../../build/serializers/ng-snapshot', | ||
'<rootDir>/../../build/serializers/no-ng-attributes', | ||
], | ||
setupFilesAfterEnv: ['./setup-zoneless-env.ts'], | ||
transform: { | ||
'^.+\\.(ts|js|mjs|html)$': [ | ||
'<rootDir>/../../build/index.js', | ||
{ | ||
tsconfig: '<rootDir>/tsconfig-cjs.spec.json', | ||
stringifyContentPathRegex: '\\.(html|svg)$', | ||
isolatedModules: true, | ||
}, | ||
], | ||
}, | ||
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'], | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { JestConfigWithTsJest } from 'ts-jest'; | ||
|
||
const config: JestConfigWithTsJest = { | ||
displayName: 'e2e-snapshot-serializers', | ||
testEnvironment: 'jsdom', | ||
snapshotSerializers: [ | ||
'<rootDir>/../../build/serializers/html-comment', | ||
'<rootDir>/../../build/serializers/ng-snapshot', | ||
'<rootDir>/../../build/serializers/no-ng-attributes', | ||
], | ||
setupFilesAfterEnv: ['./setup-zoneless-env.mts'], | ||
moduleNameMapper: { | ||
rxjs: '<rootDir>/../../node_modules/rxjs/dist/bundles/rxjs.umd.js', | ||
}, | ||
extensionsToTreatAsEsm: ['.ts', '.mts'], | ||
transform: { | ||
'^.+\\.(ts|mts|js|mjs|html)$': [ | ||
'<rootDir>/../../build/index.js', | ||
{ | ||
useESM: true, | ||
tsconfig: '<rootDir>/tsconfig-esm.spec.json', | ||
stringifyContentPathRegex: '\\.(html|svg)$', | ||
isolatedModules: true, | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { setupZonelessTestEnv } from '../../setup-env/zoneless/index.mjs'; | ||
|
||
setupZonelessTestEnv(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { setupZonelessTestEnv } from '../../setup-env/zoneless'; | ||
|
||
setupZonelessTestEnv(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "../../tsconfig-base.spec.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "../../tsconfig-base.spec.json", | ||
"compilerOptions": { | ||
"module": "ES2022", | ||
"esModuleInterop": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.