-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
init.spec.ts
63 lines (54 loc) · 1.78 KB
/
init.spec.ts
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
import {
addDependenciesToPackageJson,
NxJsonConfiguration,
readJson,
Tree,
updateJson,
} from '@nrwl/devkit';
import { createTreeWithEmptyV1Workspace } from '@nrwl/devkit/testing';
import { nxVersion } from '../../utils/versions';
import { initGenerator } from './init';
describe('@nrwl/vite:init', () => {
let tree: Tree;
beforeEach(() => {
tree = createTreeWithEmptyV1Workspace();
});
describe('dependencies for package.json', () => {
it('should add vite packages and react-related dependencies for vite', async () => {
const existing = 'existing';
const existingVersion = '1.0.0';
addDependenciesToPackageJson(
tree,
{ '@nrwl/vite': nxVersion, [existing]: existingVersion },
{ [existing]: existingVersion }
);
await initGenerator(tree, {
uiFramework: 'react',
});
const packageJson = readJson(tree, 'package.json');
expect(packageJson).toMatchSnapshot();
});
});
describe('vitest targets', () => {
it('should add target defaults for test', async () => {
updateJson<NxJsonConfiguration>(tree, 'nx.json', (json) => {
json.namedInputs ??= {};
json.namedInputs.production = ['default'];
return json;
});
initGenerator(tree, { uiFramework: 'react' });
const productionNamedInputs = readJson(tree, 'nx.json').namedInputs
.production;
const testDefaults = readJson(tree, 'nx.json').targetDefaults.test;
expect(productionNamedInputs).toContain(
'!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)'
);
expect(productionNamedInputs).toContain(
'!{projectRoot}/tsconfig.spec.json'
);
expect(testDefaults).toEqual({
inputs: ['default', '^production'],
});
});
});
});