1- import { afterAll , beforeAll , describe , expect , test , vi } from 'vitest' ;
1+ import { describe , expect , test , vi } from 'vitest' ;
22import { testMocksDir } from '../../__tests__/fixtures.js' ;
33import * as runner from '../../testing/runner.js' ;
44import * as configs from '../../testing/utils.js' ;
@@ -13,85 +13,75 @@ describe('Test regular test command', () => {
1313 const mockedTestConfiguration = vi . spyOn ( configs , 'getTestConfiguration' ) ;
1414 const runCommand = getCommandRunner ( getTestCommand ) ;
1515
16- describe ( 'Tests that need to be CI process env invariant' , ( ) => {
17- beforeAll ( ( ) => {
18- vi . stubEnv ( 'CI' , 'yeet' ) ;
19- } ) ;
20-
21- afterAll ( ( ) => {
22- vi . unstubAllEnvs ( ) ;
23- } ) ;
24-
25- test ( 'Providing both the project directory and pattern' , async ( ) => {
26- const mockConfig : configs . GetTestConfigurationResult = {
27- severity : 'success' ,
28- config : {
29- test : {
30- name : 'Test0'
31- }
16+ test ( 'Providing both the project directory and pattern' , async ( ) => {
17+ const mockConfig : configs . GetTestConfigurationResult = {
18+ severity : 'success' ,
19+ config : {
20+ test : {
21+ name : 'Test0'
3222 }
33- } ;
23+ }
24+ } ;
3425
35- mockedTestConfiguration . mockResolvedValueOnce ( mockConfig ) ;
36- const projectPath = `${ testMocksDir } /dir` ;
26+ mockedTestConfiguration . mockResolvedValueOnce ( mockConfig ) ;
27+ const projectPath = `${ testMocksDir } /dir` ;
3728
38- await expect ( runCommand ( '--project' , projectPath , `${ projectPath } /dir1` ) ) . commandSuccess ( ) ;
39- expect ( configs . getTestConfiguration ) . toHaveBeenCalledExactlyOnceWith ( projectPath , false ) ;
40- expect ( runner . runVitest ) . toHaveBeenCalledExactlyOnceWith ( 'test' , [ `${ projectPath } /dir1` ] , [ mockConfig . config ] , { allowOnly : true } ) ;
41- } ) ;
29+ await expect ( runCommand ( '--project' , projectPath , `${ projectPath } /dir1` ) ) . commandSuccess ( ) ;
30+ expect ( configs . getTestConfiguration ) . toHaveBeenCalledExactlyOnceWith ( projectPath , false ) ;
31+ expect ( runner . runVitest ) . toHaveBeenCalledExactlyOnceWith ( 'test' , [ `${ projectPath } /dir1` ] , [ mockConfig . config ] , { allowOnly : expect . any ( Boolean ) } ) ;
32+ } ) ;
4233
43- test ( 'Providing both the project directory but no patterns' , async ( ) => {
44- const projectPath = `${ testMocksDir } /dir` ;
45- const mockConfig : configs . GetTestConfigurationResult = {
46- severity : 'success' ,
47- config : {
48- test : {
49- name : 'Test0'
50- }
34+ test ( 'Providing both the project directory but no patterns' , async ( ) => {
35+ const projectPath = `${ testMocksDir } /dir` ;
36+ const mockConfig : configs . GetTestConfigurationResult = {
37+ severity : 'success' ,
38+ config : {
39+ test : {
40+ name : 'Test0'
5141 }
52- } ;
42+ }
43+ } ;
5344
54- mockedTestConfiguration . mockResolvedValueOnce ( mockConfig ) ;
45+ mockedTestConfiguration . mockResolvedValueOnce ( mockConfig ) ;
5546
56- await expect ( runCommand ( '--project' , projectPath ) ) . commandSuccess ( ) ;
57- expect ( configs . getTestConfiguration ) . toHaveBeenCalledExactlyOnceWith ( projectPath , false ) ;
58- expect ( runner . runVitest ) . toHaveBeenCalledExactlyOnceWith ( 'test' , [ ] , [ mockConfig . config ] , { allowOnly : true } ) ;
59- } ) ;
60-
61- test ( 'Expect command to exit with no issues if no tests were found' , async ( ) => {
62- const projectPath = `${ testMocksDir } /dir` ;
63- mockedTestConfiguration . mockResolvedValueOnce ( {
64- severity : 'success' ,
65- config : null
66- } ) ;
47+ await expect ( runCommand ( '--project' , projectPath ) ) . commandSuccess ( ) ;
48+ expect ( configs . getTestConfiguration ) . toHaveBeenCalledExactlyOnceWith ( projectPath , false ) ;
49+ expect ( runner . runVitest ) . toHaveBeenCalledExactlyOnceWith ( 'test' , [ ] , [ mockConfig . config ] , { allowOnly : expect . any ( Boolean ) } ) ;
50+ } ) ;
6751
68- await expect ( runCommand ( '--project' , projectPath ) ) . commandSuccess ( ) ;
52+ test ( 'Expect command to exit with no issues if no tests were found' , async ( ) => {
53+ const projectPath = `${ testMocksDir } /dir` ;
54+ mockedTestConfiguration . mockResolvedValueOnce ( {
55+ severity : 'success' ,
56+ config : null
6957 } ) ;
7058
71- test ( 'Command should error if the command was called from beyond the git root' , async ( ) => {
72- const projectPath = `${ testMocksDir } /..` ;
73- await expect ( runCommand ( '--project' , projectPath ) ) . commandExit ( ) ;
74- } ) ;
59+ await expect ( runCommand ( '--project' , projectPath ) ) . commandSuccess ( ) ;
60+ } ) ;
7561
76- test ( '--no-allow-only should not allow only :)' , async ( ) => {
77- const mockConfig : configs . GetTestConfigurationResult = {
78- severity : 'success' ,
79- config : {
80- test : {
81- name : 'Test0'
82- }
83- }
84- } ;
85- mockedTestConfiguration . mockResolvedValueOnce ( mockConfig ) ;
62+ test ( 'Command should error if the command was called from beyond the git root' , async ( ) => {
63+ const projectPath = `${ testMocksDir } /..` ;
64+ await expect ( runCommand ( '--project' , projectPath ) ) . commandExit ( ) ;
65+ } ) ;
8666
87- await expect ( runCommand ( '--no-allow-only' ) ) . commandSuccess ( ) ;
88- expect ( runner . runVitest ) . toHaveBeenCalledExactlyOnceWith (
89- 'test' ,
90- [ ] ,
91- [ mockConfig . config ] ,
92- { allowOnly : false }
93- ) ;
94- } ) ;
67+ test ( '--no-allow-only should not allow only' , async ( ) => {
68+ const mockConfig : configs . GetTestConfigurationResult = {
69+ severity : 'success' ,
70+ config : {
71+ test : {
72+ name : 'Test0'
73+ }
74+ }
75+ } ;
76+ mockedTestConfiguration . mockResolvedValueOnce ( mockConfig ) ;
77+
78+ await expect ( runCommand ( '--no-allow-only' ) ) . commandSuccess ( ) ;
79+ expect ( runner . runVitest ) . toHaveBeenCalledExactlyOnceWith (
80+ 'test' ,
81+ [ ] ,
82+ [ mockConfig . config ] ,
83+ { allowOnly : false }
84+ ) ;
9585 } ) ;
9686
9787 test ( '--no-allow-only should be true when CI' , async ( ) => {
0 commit comments