-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Expand file tree
/
Copy pathtslib-resolution.ts
More file actions
71 lines (61 loc) · 1.76 KB
/
tslib-resolution.ts
File metadata and controls
71 lines (61 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { writeFile } from '../../utils/fs';
import { installPackage } from '../../utils/packages';
import { ng } from '../../utils/process';
import { applyVitestBuilder } from '../../utils/vitest';
import assert from 'node:assert';
export default async function () {
await applyVitestBuilder();
await installPackage('playwright@1');
await installPackage('@vitest/browser-playwright@4');
// Add a custom decorator to trigger tslib usage
await writeFile(
'src/app/custom-decorator.ts',
`
export function MyDecorator() {
return function (originalMethod: any, context: ClassMethodDecoratorContext) {
// do nothing
};
}
`,
);
// Add a service that uses the decorator
await writeFile(
'src/app/test.service.ts',
`
import { Injectable } from '@angular/core';
import { MyDecorator } from './custom-decorator';
@Injectable({
providedIn: 'root'
})
export class TestService {
@MyDecorator()
myMethod() {
return true;
}
}
`,
);
// Add a test for the service
await writeFile(
'src/app/test.service.spec.ts',
`
import { TestBed } from '@angular/core/testing';
import { TestService } from './test.service';
describe('TestService', () => {
let service: TestService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(TestService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
it('myMethod should return true', () => {
expect(service.myMethod()).toBe(true);
});
});
`,
);
const { stdout } = await ng('test', '--no-watch', '--browsers', 'chromiumHeadless');
assert.match(stdout, /2 passed/, 'Expected 2 tests to pass.');
}