Skip to content

Commit 00972a8

Browse files
authored
feat(custom-esbuild): add unit-test builder (#1935)
1 parent ae2a34f commit 00972a8

File tree

36 files changed

+4782
-3394
lines changed

36 files changed

+4782
-3394
lines changed

examples/bazel/MODULE.bazel.lock

Lines changed: 11 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/custom-esbuild/sanity-esbuild-app-esm/angular.json

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -126,24 +126,23 @@
126126
"defaultConfiguration": "cjs"
127127
},
128128
"test": {
129-
"builder": "@angular-devkit/build-angular:karma",
129+
"builder": "@angular-builders/custom-esbuild:unit-test",
130130
"options": {
131-
"polyfills": [
132-
"zone.js",
133-
"zone.js/testing"
134-
],
135-
"tsConfig": "tsconfig.spec.json",
136-
"karmaConfig": "karma.conf.cjs",
137-
"inlineStyleLanguage": "scss",
138-
"assets": [
139-
"src/favicon.ico",
140-
"src/assets"
141-
],
142-
"styles": [
143-
"src/styles.scss"
144-
],
145-
"scripts": []
146-
}
131+
"buildTarget": "sanity-esbuild-app-esm:build",
132+
"tsConfig": "tsconfig.spec.json"
133+
},
134+
"configurations": {
135+
"esm": {
136+
"buildTarget": "sanity-esbuild-app-esm:build:esm"
137+
},
138+
"cjs": {
139+
"buildTarget": "sanity-esbuild-app-esm:build:cjs"
140+
},
141+
"tsEsm": {
142+
"buildTarget": "sanity-esbuild-app-esm:build:tsEsm"
143+
}
144+
},
145+
"defaultConfiguration": "cjs"
147146
},
148147
"e2e": {
149148
"builder": "@cypress/schematic:cypress",

examples/custom-esbuild/sanity-esbuild-app-esm/karma.conf.cjs

Lines changed: 0 additions & 50 deletions
This file was deleted.

examples/custom-esbuild/sanity-esbuild-app-esm/package.json

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,47 +8,42 @@
88
"build": "ng build",
99
"build-ts": "TS_NODE_PROJECT=tsconfig.app.json NODE_OPTIONS='--loader ts-node/esm' ng build",
1010
"test": "ng test",
11+
"test-ts": "TS_NODE_PROJECT=tsconfig.spec.json NODE_OPTIONS='--loader ts-node/esm' ng test",
1112
"lint": "ng lint",
1213
"e2e": "ng e2e",
1314
"cypress:open": "cypress open",
1415
"cypress:run": "cypress run"
1516
},
1617
"private": true,
1718
"dependencies": {
18-
"@angular/animations": "20.0.3",
19-
"@angular/common": "20.0.3",
20-
"@angular/compiler": "20.0.3",
21-
"@angular/core": "20.0.3",
22-
"@angular/forms": "20.0.3",
23-
"@angular/platform-browser": "20.0.3",
24-
"@angular/platform-browser-dynamic": "20.0.3",
25-
"@angular/router": "20.0.3",
19+
"@angular/animations": "20.3.9",
20+
"@angular/common": "20.3.9",
21+
"@angular/compiler": "20.3.9",
22+
"@angular/core": "20.3.9",
23+
"@angular/forms": "20.3.9",
24+
"@angular/platform-browser": "20.3.9",
25+
"@angular/platform-browser-dynamic": "20.3.9",
26+
"@angular/router": "20.3.9",
2627
"rxjs": "7.8.2",
2728
"tslib": "2.8.1",
2829
"zone.js": "0.15.0"
2930
},
3031
"devDependencies": {
3132
"@angular-builders/custom-esbuild": "workspace:*",
32-
"@angular-devkit/build-angular": "20.0.3",
33-
"@angular-eslint/builder": "20.1.0",
34-
"@angular/cli": "20.0.3",
35-
"@angular/compiler-cli": "20.0.3",
36-
"@angular/language-service": "20.0.3",
33+
"@angular-devkit/build-angular": "20.3.9",
34+
"@angular-eslint/builder": "20.6.0",
35+
"@angular/cli": "20.3.9",
36+
"@angular/compiler-cli": "20.3.9",
37+
"@angular/language-service": "20.3.9",
3738
"@eslint/js": "^9.29.0",
38-
"@types/jasmine": "5.1.5",
3939
"@types/node": "20.17.12",
40-
"angular-eslint": "20.1.0",
41-
"cypress": "14.4.1",
40+
"angular-eslint": "20.6.0",
41+
"cypress": "15.3.0",
4242
"eslint": "^9.29.0",
43-
"jasmine-core": "5.5.0",
44-
"karma": "6.4.4",
45-
"karma-chrome-launcher": "3.2.0",
46-
"karma-coverage": "2.2.1",
47-
"karma-jasmine": "5.1.0",
48-
"karma-jasmine-html-reporter": "2.1.0",
4943
"puppeteer": "24.10.1",
5044
"ts-node": "10.9.2",
5145
"typescript": "5.8.3",
52-
"typescript-eslint": "8.34.0"
46+
"typescript-eslint": "8.34.0",
47+
"vitest": "3.2.4"
5348
}
5449
}
Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,46 @@
1-
import { TestBed, waitForAsync } from '@angular/core/testing';
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
22
import { AppComponent } from './app.component';
33

44
describe('AppComponent', () => {
5-
beforeEach(waitForAsync(() => {
6-
TestBed.configureTestingModule({
5+
let fixture: ComponentFixture<AppComponent>;
6+
let appElem: HTMLElement;
7+
8+
beforeEach(async () => {
9+
await TestBed.configureTestingModule({
710
imports: [AppComponent],
811
}).compileComponents();
9-
}));
12+
13+
fixture = TestBed.createComponent(AppComponent);
14+
fixture.detectChanges();
15+
16+
appElem = fixture.debugElement.nativeElement;
17+
});
1018

1119
it('should create the app', () => {
12-
const fixture = TestBed.createComponent(AppComponent);
1320
const app = fixture.debugElement.componentInstance;
1421
expect(app).toBeTruthy();
1522
});
1623

24+
it(`should have as title 'sanity-esbuild-app-esm'`, () => {
25+
const app = fixture.debugElement.componentInstance;
26+
expect(app.title).toEqual('sanity-esbuild-app-esm (compilation provided)');
27+
});
28+
1729
it('should render title in a h1 tag', () => {
18-
const fixture = TestBed.createComponent(AppComponent);
19-
fixture.detectChanges();
20-
const compiled = fixture.debugElement.nativeElement;
21-
expect(compiled.querySelector('h1').textContent).toContain('sanity-esbuild-app-esm');
30+
expect(appElem.querySelector('h1')!.textContent).toContain(
31+
'sanity-esbuild-app-esm (compilation provided)'
32+
);
33+
});
34+
35+
it('should render subtitle in a h2 tag', () => {
36+
expect(appElem.querySelector('h2')!.textContent).toContain(
37+
'sanity-esbuild-app-esm subtitle (compilation provided)'
38+
);
39+
});
40+
41+
it('should render titleByOption in a h3 tag', () => {
42+
expect(appElem.querySelector('h3')!.textContent).toContain(
43+
'sanity-esbuild-app-esm optionTitle (compilation provided)'
44+
);
2245
});
2346
});

examples/custom-esbuild/sanity-esbuild-app-esm/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"lib": [
2323
"ES2022",
2424
"dom"
25-
]
25+
],
26+
"skipLibCheck": true
2627
},
2728
"angularCompilerOptions": {
2829
"enableI18nLegacyMessageIdFormat": false,

examples/custom-esbuild/sanity-esbuild-app-esm/tsconfig.spec.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"compilerOptions": {
55
"outDir": "./out-tsc/spec",
66
"types": [
7-
"jasmine"
7+
"vitest/globals"
88
]
99
},
1010
"include": [

examples/custom-esbuild/sanity-esbuild-app/angular.json

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -109,24 +109,20 @@
109109
"defaultConfiguration": "cjs"
110110
},
111111
"test": {
112-
"builder": "@angular-devkit/build-angular:karma",
112+
"builder": "@angular-builders/custom-esbuild:unit-test",
113113
"options": {
114-
"polyfills": [
115-
"zone.js",
116-
"zone.js/testing"
117-
],
118-
"tsConfig": "tsconfig.spec.json",
119-
"karmaConfig": "karma.conf.js",
120-
"inlineStyleLanguage": "scss",
121-
"assets": [
122-
"src/favicon.ico",
123-
"src/assets"
124-
],
125-
"styles": [
126-
"src/styles.scss"
127-
],
128-
"scripts": []
129-
}
114+
"buildTarget": "sanity-esbuild-app:build",
115+
"tsConfig": "tsconfig.spec.json"
116+
},
117+
"configurations": {
118+
"esm": {
119+
"buildTarget": "sanity-esbuild-app:build:esm"
120+
},
121+
"cjs": {
122+
"buildTarget": "sanity-esbuild-app:build:cjs"
123+
}
124+
},
125+
"defaultConfiguration": "cjs"
130126
},
131127
"e2e": {
132128
"builder": "@cypress/schematic:cypress",

examples/custom-esbuild/sanity-esbuild-app/karma.conf.js

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)