|
| 1 | +import { |
| 2 | + killAllProcesses, |
| 3 | + waitForAnyProcessOutputToMatch, |
| 4 | + execAndWaitForOutputToMatch |
| 5 | +} from '../../utils/process'; |
| 6 | +import { appendToFile } from '../../utils/fs'; |
| 7 | +import { getGlobalVariable } from '../../utils/env'; |
| 8 | +import { updateJsonFile } from '../../utils/project'; |
| 9 | + |
| 10 | +const webpackGoodRegEx = /webpack: Compiled successfully./; |
| 11 | +const webpackWarningRegEx = /webpack: Compiled with warnings./; |
| 12 | + |
| 13 | +export default function () { |
| 14 | + if (process.platform.startsWith('win')) { |
| 15 | + return Promise.resolve(); |
| 16 | + } |
| 17 | + // Skip this in ejected tests. |
| 18 | + if (getGlobalVariable('argv').eject) { |
| 19 | + return Promise.resolve(); |
| 20 | + } |
| 21 | + |
| 22 | + |
| 23 | + return execAndWaitForOutputToMatch('ng', ['serve'], webpackGoodRegEx) |
| 24 | + // Should trigger a rebuild. |
| 25 | + .then(() => appendToFile('src/app/app.component.css', 'body { color: var(--white); }')) |
| 26 | + // Should see some warnings |
| 27 | + .then(() => waitForAnyProcessOutputToMatch(webpackWarningRegEx, 10000)) |
| 28 | + .then(() => killAllProcesses(), (err: any) => { |
| 29 | + killAllProcesses(); |
| 30 | + throw err; |
| 31 | + }) |
| 32 | + // update withPostCssWarnings flag |
| 33 | + .then(() => updateJsonFile('.angular-cli.json', configJson => { |
| 34 | + configJson['defaults']['build'] = {}; |
| 35 | + configJson['defaults']['build']['withPostCssWarnings'] = false |
| 36 | + })) |
| 37 | + // should remove warnings |
| 38 | + .then(() => execAndWaitForOutputToMatch('ng', ['serve'], webpackGoodRegEx)) |
| 39 | + .then(() => killAllProcesses(), (err: any) => { |
| 40 | + killAllProcesses(); |
| 41 | + throw err; |
| 42 | + }) |
| 43 | +} |
0 commit comments