|
9 | 9 | /* eslint-disable max-len */
|
10 | 10 | import { concatMap, count, take, timeout } from 'rxjs';
|
11 | 11 | import { URL } from 'url';
|
12 |
| -import { serveWebpackBrowser } from '../../index'; |
13 |
| -import { |
14 |
| - BASE_OPTIONS, |
15 |
| - BUILD_TIMEOUT, |
16 |
| - DEV_SERVER_BUILDER_INFO, |
17 |
| - describeBuilder, |
18 |
| - setupBrowserTarget, |
19 |
| -} from '../setup'; |
| 12 | +import { executeDevServer } from '../../index'; |
| 13 | +import { describeServeBuilder } from '../jasmine-helpers'; |
| 14 | +import { BASE_OPTIONS, BUILD_TIMEOUT, DEV_SERVER_BUILDER_INFO } from '../setup'; |
20 | 15 |
|
21 |
| -describeBuilder(serveWebpackBrowser, DEV_SERVER_BUILDER_INFO, (harness) => { |
22 |
| - describe('Behavior: "i18n $localize calls are replaced during watching"', () => { |
23 |
| - beforeEach(() => { |
24 |
| - harness.useProject('test', { |
25 |
| - root: '.', |
26 |
| - sourceRoot: 'src', |
27 |
| - cli: { |
28 |
| - cache: { |
29 |
| - enabled: false, |
30 |
| - }, |
31 |
| - }, |
32 |
| - i18n: { |
33 |
| - sourceLocale: { |
34 |
| - 'code': 'fr', |
35 |
| - }, |
36 |
| - }, |
37 |
| - }); |
| 16 | +describeServeBuilder( |
| 17 | + executeDevServer, |
| 18 | + DEV_SERVER_BUILDER_INFO, |
| 19 | + (harness, setupTarget, isViteRun) => { |
| 20 | + // TODO(fix-vite): currently this is broken in vite. |
| 21 | + (isViteRun ? xdescribe : describe)( |
| 22 | + 'Behavior: "i18n $localize calls are replaced during watching"', |
| 23 | + () => { |
| 24 | + beforeEach(() => { |
| 25 | + harness.useProject('test', { |
| 26 | + root: '.', |
| 27 | + sourceRoot: 'src', |
| 28 | + cli: { |
| 29 | + cache: { |
| 30 | + enabled: false, |
| 31 | + }, |
| 32 | + }, |
| 33 | + i18n: { |
| 34 | + sourceLocale: { |
| 35 | + 'code': 'fr', |
| 36 | + }, |
| 37 | + }, |
| 38 | + }); |
38 | 39 |
|
39 |
| - setupBrowserTarget(harness, { localize: ['fr'] }); |
40 |
| - }); |
| 40 | + setupTarget(harness, { localize: ['fr'] }); |
| 41 | + }); |
41 | 42 |
|
42 |
| - it('$localize are replaced in watch', async () => { |
43 |
| - harness.useTarget('serve', { |
44 |
| - ...BASE_OPTIONS, |
45 |
| - }); |
| 43 | + it('$localize are replaced in watch', async () => { |
| 44 | + harness.useTarget('serve', { |
| 45 | + ...BASE_OPTIONS, |
| 46 | + watch: true, |
| 47 | + }); |
46 | 48 |
|
47 |
| - await harness.writeFile( |
48 |
| - 'src/app/app.component.html', |
49 |
| - ` |
| 49 | + await harness.writeFile( |
| 50 | + 'src/app/app.component.html', |
| 51 | + ` |
50 | 52 | <p id="hello" i18n="An introduction header for this sample">Hello {{ title }}! </p>
|
51 | 53 | `,
|
52 |
| - ); |
| 54 | + ); |
53 | 55 |
|
54 |
| - const buildCount = await harness |
55 |
| - .execute() |
56 |
| - .pipe( |
57 |
| - timeout(BUILD_TIMEOUT * 2), |
58 |
| - concatMap(async ({ result }, index) => { |
59 |
| - expect(result?.success).toBe(true); |
| 56 | + const buildCount = await harness |
| 57 | + .execute() |
| 58 | + .pipe( |
| 59 | + timeout(BUILD_TIMEOUT * 2), |
| 60 | + concatMap(async ({ result }, index) => { |
| 61 | + expect(result?.success).toBe(true); |
60 | 62 |
|
61 |
| - const response = await fetch(new URL('main.js', `${result?.baseUrl}`)); |
62 |
| - expect(await response?.text()).not.toContain('$localize`:'); |
| 63 | + const response = await fetch(new URL('main.js', `${result?.baseUrl}`)); |
| 64 | + expect(await response?.text()).not.toContain('$localize`:'); |
63 | 65 |
|
64 |
| - switch (index) { |
65 |
| - case 0: { |
66 |
| - await harness.modifyFile('src/app/app.component.html', (content) => |
67 |
| - content.replace('introduction', 'intro'), |
68 |
| - ); |
69 |
| - break; |
70 |
| - } |
71 |
| - } |
72 |
| - }), |
73 |
| - take(2), |
74 |
| - count(), |
75 |
| - ) |
76 |
| - .toPromise(); |
| 66 | + switch (index) { |
| 67 | + case 0: { |
| 68 | + await harness.modifyFile('src/app/app.component.html', (content) => |
| 69 | + content.replace('introduction', 'intro'), |
| 70 | + ); |
| 71 | + break; |
| 72 | + } |
| 73 | + } |
| 74 | + }), |
| 75 | + take(2), |
| 76 | + count(), |
| 77 | + ) |
| 78 | + .toPromise(); |
77 | 79 |
|
78 |
| - expect(buildCount).toBe(2); |
79 |
| - }); |
80 |
| - }); |
81 |
| -}); |
| 80 | + expect(buildCount).toBe(2); |
| 81 | + }); |
| 82 | + }, |
| 83 | + ); |
| 84 | + }, |
| 85 | +); |
0 commit comments