-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Expand file tree
/
Copy pathbundle-budgets.ts
More file actions
43 lines (37 loc) · 1.45 KB
/
bundle-budgets.ts
File metadata and controls
43 lines (37 loc) · 1.45 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
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import assert from 'node:assert/strict';
import { ng } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';
import { expectToFail } from '../../utils/utils';
export default async function () {
// Error
await updateJsonFile('angular.json', (json) => {
json.projects['test-project'].architect.build.configurations.production.budgets = [
{ type: 'all', maximumError: '100b' },
];
});
const { message: errorMessage } = await expectToFail(() => ng('build'));
assert.match(errorMessage, /Error.+budget/i, 'Budget error: all, max error.');
// Warning
await updateJsonFile('angular.json', (json) => {
json.projects['test-project'].architect.build.configurations.production.budgets = [
{ type: 'all', minimumWarning: '100mb' },
];
});
const { stderr } = await ng('build');
assert.match(stderr, /Warning.+budget/i, 'Budget warning: all, min warning');
// Pass
await updateJsonFile('angular.json', (json) => {
json.projects['test-project'].architect.build.configurations.production.budgets = [
{ type: 'allScript', maximumError: '100mb' },
];
});
const { stderr: stderr2 } = await ng('build');
assert.doesNotMatch(stderr2, /(Warning|Error)/i, 'BIG max for all, should not error');
}