Skip to content

Commit a9fa561

Browse files
committed
test(@angular-devkit/build-angular): enable dev-server watch tests for vite
These tests can now be enabled.
1 parent 2d4b548 commit a9fa561

File tree

1 file changed

+94
-99
lines changed
  • packages/angular_devkit/build_angular/src/builders/dev-server/tests/options

1 file changed

+94
-99
lines changed

packages/angular_devkit/build_angular/src/builders/dev-server/tests/options/watch_spec.ts

Lines changed: 94 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -11,116 +11,111 @@ import { executeDevServer } from '../../index';
1111
import { describeServeBuilder } from '../jasmine-helpers';
1212
import { BASE_OPTIONS, BUILD_TIMEOUT, DEV_SERVER_BUILDER_INFO } from '../setup';
1313

14-
describeServeBuilder(
15-
executeDevServer,
16-
DEV_SERVER_BUILDER_INFO,
17-
(harness, setupTarget, isViteRun) => {
18-
// TODO(fix-vite): currently this is broken in vite.
19-
(isViteRun ? xdescribe : describe)('Option: "watch"', () => {
20-
beforeEach(() => {
21-
setupTarget(harness);
22-
});
14+
describeServeBuilder(executeDevServer, DEV_SERVER_BUILDER_INFO, (harness, setupTarget) => {
15+
describe('Option: "watch"', () => {
16+
beforeEach(() => {
17+
setupTarget(harness);
18+
});
2319

24-
it('does not wait for file changes when false', async () => {
25-
harness.useTarget('serve', {
26-
...BASE_OPTIONS,
27-
watch: false,
28-
});
20+
it('does not wait for file changes when false', async () => {
21+
harness.useTarget('serve', {
22+
...BASE_OPTIONS,
23+
watch: false,
24+
});
2925

30-
await harness
31-
.execute()
32-
.pipe(
33-
timeout(BUILD_TIMEOUT),
34-
concatMap(async ({ result }, index) => {
35-
expect(result?.success).toBe(true);
26+
await harness
27+
.execute()
28+
.pipe(
29+
timeout(BUILD_TIMEOUT),
30+
concatMap(async ({ result }, index) => {
31+
expect(result?.success).toBe(true);
3632

37-
switch (index) {
38-
case 0:
39-
await harness.modifyFile(
40-
'src/main.ts',
41-
(content) => content + 'console.log("abcd1234");',
42-
);
43-
break;
44-
case 1:
45-
fail('Expected files to not be watched.');
46-
break;
47-
}
48-
}),
49-
take(2),
50-
)
51-
.toPromise()
52-
.catch((error) => {
53-
// Timeout is expected if watching is disabled
54-
if (error instanceof TimeoutError) {
55-
return;
33+
switch (index) {
34+
case 0:
35+
await harness.modifyFile(
36+
'src/main.ts',
37+
(content) => content + 'console.log("abcd1234");',
38+
);
39+
break;
40+
case 1:
41+
fail('Expected files to not be watched.');
42+
break;
5643
}
57-
throw error;
58-
});
44+
}),
45+
take(2),
46+
)
47+
.toPromise()
48+
.catch((error) => {
49+
// Timeout is expected if watching is disabled
50+
if (error instanceof TimeoutError) {
51+
return;
52+
}
53+
throw error;
54+
});
55+
});
56+
57+
it('watches for file changes when not present', async () => {
58+
harness.useTarget('serve', {
59+
...BASE_OPTIONS,
60+
watch: undefined,
5961
});
6062

61-
it('watches for file changes when not present', async () => {
62-
harness.useTarget('serve', {
63-
...BASE_OPTIONS,
64-
watch: undefined,
65-
});
63+
const buildCount = await harness
64+
.execute()
65+
.pipe(
66+
timeout(BUILD_TIMEOUT),
67+
concatMap(async ({ result }, index) => {
68+
expect(result?.success).toBe(true);
6669

67-
const buildCount = await harness
68-
.execute()
69-
.pipe(
70-
timeout(BUILD_TIMEOUT),
71-
concatMap(async ({ result }, index) => {
72-
expect(result?.success).toBe(true);
70+
switch (index) {
71+
case 0:
72+
await harness.modifyFile(
73+
'src/main.ts',
74+
(content) => content + 'console.log("abcd1234");',
75+
);
76+
break;
77+
case 1:
78+
break;
79+
}
80+
}),
81+
take(2),
82+
count(),
83+
)
84+
.toPromise();
7385

74-
switch (index) {
75-
case 0:
76-
await harness.modifyFile(
77-
'src/main.ts',
78-
(content) => content + 'console.log("abcd1234");',
79-
);
80-
break;
81-
case 1:
82-
break;
83-
}
84-
}),
85-
take(2),
86-
count(),
87-
)
88-
.toPromise();
86+
expect(buildCount).toBe(2);
87+
});
8988

90-
expect(buildCount).toBe(2);
89+
it('watches for file changes when true', async () => {
90+
harness.useTarget('serve', {
91+
...BASE_OPTIONS,
92+
watch: true,
9193
});
9294

93-
it('watches for file changes when true', async () => {
94-
harness.useTarget('serve', {
95-
...BASE_OPTIONS,
96-
watch: true,
97-
});
95+
const buildCount = await harness
96+
.execute()
97+
.pipe(
98+
timeout(BUILD_TIMEOUT),
99+
concatMap(async ({ result }, index) => {
100+
expect(result?.success).toBe(true);
98101

99-
const buildCount = await harness
100-
.execute()
101-
.pipe(
102-
timeout(BUILD_TIMEOUT),
103-
concatMap(async ({ result }, index) => {
104-
expect(result?.success).toBe(true);
105-
106-
switch (index) {
107-
case 0:
108-
await harness.modifyFile(
109-
'src/main.ts',
110-
(content) => content + 'console.log("abcd1234");',
111-
);
112-
break;
113-
case 1:
114-
break;
115-
}
116-
}),
117-
take(2),
118-
count(),
119-
)
120-
.toPromise();
102+
switch (index) {
103+
case 0:
104+
await harness.modifyFile(
105+
'src/main.ts',
106+
(content) => content + 'console.log("abcd1234");',
107+
);
108+
break;
109+
case 1:
110+
break;
111+
}
112+
}),
113+
take(2),
114+
count(),
115+
)
116+
.toPromise();
121117

122-
expect(buildCount).toBe(2);
123-
});
118+
expect(buildCount).toBe(2);
124119
});
125-
},
126-
);
120+
});
121+
});

0 commit comments

Comments
 (0)