1
- import { scaffoldMigrationProject , fakeDepsInNodeModules } from './detect.spec'
1
+ import { describe , it , expect , beforeEach , afterEach } from 'vitest'
2
+ import { scaffoldMigrationProject , fakeDepsInNodeModules } from './scaffolding'
2
3
import fs from 'fs-extra'
3
4
import path from 'path'
4
- import { detectThirdPartyCTFrameworks , validateThirdPartyModule , isThirdPartyDefinition , isRepositoryRoot } from '../../src'
5
- import { expect } from 'chai'
5
+ import { detectThirdPartyCTFrameworks , validateThirdPartyModule , isThirdPartyDefinition , isRepositoryRoot } from '../src'
6
6
import os from 'os'
7
7
import solidJs from './fixtures'
8
8
@@ -25,31 +25,31 @@ async function scaffoldQwikApp (thirdPartyModuleNames: Array<'cypress-ct-qwik' |
25
25
}
26
26
27
27
describe ( 'isThirdPartyDefinition' , ( ) => {
28
- context ( 'global package' , ( ) => {
28
+ describe ( 'global package' , ( ) => {
29
29
it ( 'returns false for invalid prefix' , ( ) => {
30
30
const res = isThirdPartyDefinition ( { ...solidJs , type : 'non-cypress-ct' } )
31
31
32
- expect ( res ) . to . be . false
32
+ expect ( res ) . toBe ( false )
33
33
} )
34
34
35
35
it ( 'returns true for valid prefix' , ( ) => {
36
36
const res = isThirdPartyDefinition ( { ...solidJs , type : 'cypress-ct-solid-js' } )
37
37
38
- expect ( res ) . to . be . true
38
+ expect ( res ) . toBe ( true )
39
39
} )
40
40
} )
41
41
42
- context ( 'namespaced package' , ( ) => {
42
+ describe ( 'namespaced package' , ( ) => {
43
43
it ( 'returns false for non third party with namespace' , ( ) => {
44
44
const res = isThirdPartyDefinition ( { ...solidJs , type : '@org/non-cypress-ct' } )
45
45
46
- expect ( res ) . to . be . false
46
+ expect ( res ) . toBe ( false )
47
47
} )
48
48
49
49
it ( 'returns true for third party with namespace' , ( ) => {
50
50
const res = isThirdPartyDefinition ( { ...solidJs , type : '@org/cypress-ct-solid-js' } )
51
51
52
- expect ( res ) . to . be . true
52
+ expect ( res ) . toBe ( true )
53
53
} )
54
54
} )
55
55
} )
@@ -68,15 +68,15 @@ describe('isRepositoryRoot', () => {
68
68
it ( 'returns false if there is nothing in the directory' , async ( ) => {
69
69
const isCurrentRepositoryRoot = await isRepositoryRoot ( TEMP_DIR )
70
70
71
- expect ( isCurrentRepositoryRoot ) . to . be . false
71
+ expect ( isCurrentRepositoryRoot ) . toBe ( false )
72
72
} )
73
73
74
74
it ( 'returns true if there is a Git directory' , async ( ) => {
75
75
await fs . mkdir ( path . join ( TEMP_DIR , '.git' ) )
76
76
77
77
const isCurrentRepositoryRoot = await isRepositoryRoot ( TEMP_DIR )
78
78
79
- expect ( isCurrentRepositoryRoot ) . to . be . true
79
+ expect ( isCurrentRepositoryRoot ) . toBe ( true )
80
80
} )
81
81
82
82
it ( 'returns false if there is a package.json without workspaces field' , async ( ) => {
@@ -91,7 +91,7 @@ describe('isRepositoryRoot', () => {
91
91
92
92
const isCurrentRepositoryRoot = await isRepositoryRoot ( TEMP_DIR )
93
93
94
- expect ( isCurrentRepositoryRoot ) . to . be . false
94
+ expect ( isCurrentRepositoryRoot ) . toBe ( false )
95
95
} )
96
96
97
97
it ( 'returns true if there is a package.json with workspaces field' , async ( ) => {
@@ -109,7 +109,7 @@ describe('isRepositoryRoot', () => {
109
109
110
110
const isCurrentRepositoryRoot = await isRepositoryRoot ( TEMP_DIR )
111
111
112
- expect ( isCurrentRepositoryRoot ) . to . be . true
112
+ expect ( isCurrentRepositoryRoot ) . toBe ( true )
113
113
} )
114
114
} )
115
115
@@ -119,24 +119,24 @@ describe('detectThirdPartyCTFrameworks', () => {
119
119
120
120
const thirdPartyFrameworks = await detectThirdPartyCTFrameworks ( projectRoot )
121
121
122
- expect ( thirdPartyFrameworks . frameworks [ 0 ] . type ) . eq ( 'cypress-ct-qwik' )
122
+ expect ( thirdPartyFrameworks . frameworks [ 0 ] . type ) . toEqual ( 'cypress-ct-qwik' )
123
123
} )
124
124
125
125
it ( 'detects third party frameworks in org namespace' , async ( ) => {
126
126
const projectRoot = await scaffoldQwikApp ( [ '@org/cypress-ct-qwik' ] )
127
127
128
128
const thirdPartyFrameworks = await detectThirdPartyCTFrameworks ( projectRoot )
129
129
130
- expect ( thirdPartyFrameworks . frameworks [ 0 ] . type ) . eq ( '@org/cypress-ct-qwik' )
130
+ expect ( thirdPartyFrameworks . frameworks [ 0 ] . type ) . toEqual ( '@org/cypress-ct-qwik' )
131
131
} )
132
132
133
133
it ( 'ignores misconfigured third party frameworks' , async ( ) => {
134
134
const projectRoot = await scaffoldQwikApp ( [ 'cypress-ct-qwik' , 'misconfigured-cypress-ct-qwik' ] )
135
135
136
136
const thirdPartyFrameworks = await detectThirdPartyCTFrameworks ( projectRoot )
137
137
138
- expect ( thirdPartyFrameworks . frameworks . length ) . eq ( 1 )
139
- expect ( thirdPartyFrameworks . frameworks [ 0 ] . type ) . eq ( 'cypress-ct-qwik' )
138
+ expect ( thirdPartyFrameworks . frameworks . length ) . toEqual ( 1 )
139
+ expect ( thirdPartyFrameworks . frameworks [ 0 ] . type ) . toEqual ( 'cypress-ct-qwik' )
140
140
} )
141
141
142
142
it ( 'detects third party frameworks in monorepos with hoisted dependencies' , async ( ) => {
@@ -150,19 +150,19 @@ describe('detectThirdPartyCTFrameworks', () => {
150
150
// Look for third-party modules in packages/foo (where Cypress was launched from)
151
151
const thirdPartyFrameworks = await detectThirdPartyCTFrameworks ( projectRoot )
152
152
153
- expect ( thirdPartyFrameworks . frameworks [ 0 ] . type ) . eq ( 'cypress-ct-qwik' )
153
+ expect ( thirdPartyFrameworks . frameworks [ 0 ] . type ) . toEqual ( 'cypress-ct-qwik' )
154
154
} )
155
155
156
156
it ( 'validates third party module' , ( ) => {
157
- expect ( ( ) => validateThirdPartyModule ( solidJs ) ) . to . not . throw ( )
157
+ expect ( ( ) => validateThirdPartyModule ( solidJs ) ) . not . toThrow ( )
158
158
159
159
const gen = ( m : any ) => m
160
160
161
- expect ( ( ) => validateThirdPartyModule ( gen ( { ...solidJs , type : 'misconfigured' } ) ) ) . to . throw ( )
161
+ expect ( ( ) => validateThirdPartyModule ( gen ( { ...solidJs , type : 'misconfigured' } ) ) ) . toThrow ( )
162
162
expect ( ( ) => validateThirdPartyModule ( gen ( { ...solidJs , name : 5 } ) ) ) . to . throw ( )
163
- expect ( ( ) => validateThirdPartyModule ( gen ( { ...solidJs , supportedBundlers : [ 'random' ] } ) ) ) . to . throw ( )
164
- expect ( ( ) => validateThirdPartyModule ( gen ( { ...solidJs , detectors : { } } ) ) ) . to . throw ( )
165
- expect ( ( ) => validateThirdPartyModule ( gen ( { ...solidJs , dependencies : { } } ) ) ) . to . throw ( )
166
- expect ( ( ) => validateThirdPartyModule ( gen ( { ...solidJs , componentIndexHtml : { } } ) ) ) . to . throw ( )
163
+ expect ( ( ) => validateThirdPartyModule ( gen ( { ...solidJs , supportedBundlers : [ 'random' ] } ) ) ) . toThrow ( )
164
+ expect ( ( ) => validateThirdPartyModule ( gen ( { ...solidJs , detectors : { } } ) ) ) . toThrow ( )
165
+ expect ( ( ) => validateThirdPartyModule ( gen ( { ...solidJs , dependencies : { } } ) ) ) . toThrow ( )
166
+ expect ( ( ) => validateThirdPartyModule ( gen ( { ...solidJs , componentIndexHtml : { } } ) ) ) . toThrow ( )
167
167
} )
168
168
} )
0 commit comments