@@ -2,7 +2,7 @@ import { join, relative } from 'node:path';
2
2
import { afterEach , expect } from 'vitest' ;
3
3
import { teardownTestFolder } from '@code-pushup/test-setup' ;
4
4
import { removeColorCodes } from '@code-pushup/test-utils' ;
5
- import { executeProcess } from '@code-pushup/utils' ;
5
+ import { executeProcess , readJsonFile , readTextFile } from '@code-pushup/utils' ;
6
6
import { createNpmWorkspace } from '../mocks/create-npm-workshpace' ;
7
7
8
8
describe ( 'create-cli-inti' , ( ) => {
@@ -26,11 +26,30 @@ describe('create-cli-inti', () => {
26
26
expect ( code ) . toBe ( 0 ) ;
27
27
const cleanedStdout = removeColorCodes ( stdout ) ;
28
28
expect ( cleanedStdout ) . toContain (
29
- '<↗> Generating @code-pushup/nx-plugin:configuration' ,
29
+ '<✓> Generating @code-pushup/nx-plugin:configuration' ,
30
+ ) ;
31
+
32
+ await expect (
33
+ readJsonFile ( join ( cwd , 'package.json' ) ) ,
34
+ ) . resolves . toStrictEqual (
35
+ expect . objectContaining ( {
36
+ devDependencies : {
37
+ '@code-pushup/cli' : expect . any ( String ) ,
38
+ '@code-pushup/models' : expect . any ( String ) ,
39
+ '@code-pushup/nx-plugin' : expect . any ( String ) ,
40
+ '@code-pushup/utils' : expect . any ( String ) ,
41
+ } ,
42
+ } ) ,
43
+ ) ;
44
+ await expect (
45
+ readTextFile ( join ( cwd , 'code-pushup.config.ts' ) ) ,
46
+ ) . resolves . toContain (
47
+ "import type { CoreConfig } from '@code-pushup/models';" ,
30
48
) ;
31
49
} ) ;
32
50
33
- it ( 'should execute package correctly over npm init' , async ( ) => {
51
+ // eslint-disable-next-line vitest/no-disabled-tests
52
+ it . skip ( 'should execute package correctly over npm init' , async ( ) => {
34
53
const cwd = join ( baseDir , 'npm-init' ) ;
35
54
const userconfig = relative ( cwd , join ( workspaceRoot , '.npmrc' ) ) ;
36
55
@@ -45,7 +64,48 @@ describe('create-cli-inti', () => {
45
64
expect ( code ) . toBe ( 0 ) ;
46
65
const cleanedStdout = removeColorCodes ( stdout ) ;
47
66
expect ( cleanedStdout ) . toContain (
48
- '<↗> Generating @code-pushup/nx-plugin:configuration' ,
67
+ '<✓> Generating @code-pushup/nx-plugin:configuration' ,
68
+ ) ;
69
+
70
+ await expect (
71
+ readJsonFile ( join ( cwd , 'package.json' ) ) ,
72
+ ) . resolves . toStrictEqual (
73
+ expect . objectContaining ( {
74
+ devDependencies : {
75
+ '@code-pushup/cli' : expect . any ( String ) ,
76
+ '@code-pushup/models' : expect . any ( String ) ,
77
+ '@code-pushup/nx-plugin' : expect . any ( String ) ,
78
+ '@code-pushup/utils' : expect . any ( String ) ,
79
+ } ,
80
+ } ) ,
49
81
) ;
82
+ await expect (
83
+ readTextFile ( join ( cwd , 'code-pushup.config.ts' ) ) ,
84
+ ) . resolves . toContain (
85
+ "import type { CoreConfig } from '@code-pushup/models';" ,
86
+ ) ;
87
+ } ) ;
88
+
89
+ it ( 'should produce an executable setup when running npm init' , async ( ) => {
90
+ const cwd = join ( baseDir , 'npm-init-executable' ) ;
91
+ const userconfig = relative ( cwd , join ( workspaceRoot , '.npmrc' ) ) ;
92
+
93
+ await createNpmWorkspace ( cwd ) ;
94
+
95
+ await executeProcess ( {
96
+ command : 'npm' ,
97
+ args : [ 'init' , '@code-pushup/cli' , `--userconfig=${ userconfig } ` ] ,
98
+ cwd,
99
+ } ) ;
100
+
101
+ await expect (
102
+ executeProcess ( {
103
+ command : 'npx' ,
104
+ args : [ '@code-pushup/cli print-config' , `--userconfig=${ userconfig } ` ] ,
105
+ cwd,
106
+ } ) ,
107
+ )
108
+ // @TODO : Generate an executable setup. Edit configuration generator defaults
109
+ . rejects . toThrow ( 'Array must contain at least 1 element(s)' ) ;
50
110
} ) ;
51
111
} ) ;
0 commit comments