1- import { scaffoldMigrationProject , fakeDepsInNodeModules } from './detect.spec'
1+ import { describe , it , expect , beforeEach , afterEach } from 'vitest'
2+ import { scaffoldMigrationProject , fakeDepsInNodeModules } from './scaffolding'
23import fs from 'fs-extra'
34import path from 'path'
4- import { detectThirdPartyCTFrameworks , validateThirdPartyModule , isThirdPartyDefinition , isRepositoryRoot } from '../../src'
5- import { expect } from 'chai'
5+ import { detectThirdPartyCTFrameworks , validateThirdPartyModule , isThirdPartyDefinition , isRepositoryRoot } from '../src'
66import os from 'os'
77import solidJs from './fixtures'
88
@@ -25,31 +25,31 @@ async function scaffoldQwikApp (thirdPartyModuleNames: Array<'cypress-ct-qwik' |
2525}
2626
2727describe ( 'isThirdPartyDefinition' , ( ) => {
28- context ( 'global package' , ( ) => {
28+ describe ( 'global package' , ( ) => {
2929 it ( 'returns false for invalid prefix' , ( ) => {
3030 const res = isThirdPartyDefinition ( { ...solidJs , type : 'non-cypress-ct' } )
3131
32- expect ( res ) . to . be . false
32+ expect ( res ) . toBe ( false )
3333 } )
3434
3535 it ( 'returns true for valid prefix' , ( ) => {
3636 const res = isThirdPartyDefinition ( { ...solidJs , type : 'cypress-ct-solid-js' } )
3737
38- expect ( res ) . to . be . true
38+ expect ( res ) . toBe ( true )
3939 } )
4040 } )
4141
42- context ( 'namespaced package' , ( ) => {
42+ describe ( 'namespaced package' , ( ) => {
4343 it ( 'returns false for non third party with namespace' , ( ) => {
4444 const res = isThirdPartyDefinition ( { ...solidJs , type : '@org/non-cypress-ct' } )
4545
46- expect ( res ) . to . be . false
46+ expect ( res ) . toBe ( false )
4747 } )
4848
4949 it ( 'returns true for third party with namespace' , ( ) => {
5050 const res = isThirdPartyDefinition ( { ...solidJs , type : '@org/cypress-ct-solid-js' } )
5151
52- expect ( res ) . to . be . true
52+ expect ( res ) . toBe ( true )
5353 } )
5454 } )
5555} )
@@ -68,15 +68,15 @@ describe('isRepositoryRoot', () => {
6868 it ( 'returns false if there is nothing in the directory' , async ( ) => {
6969 const isCurrentRepositoryRoot = await isRepositoryRoot ( TEMP_DIR )
7070
71- expect ( isCurrentRepositoryRoot ) . to . be . false
71+ expect ( isCurrentRepositoryRoot ) . toBe ( false )
7272 } )
7373
7474 it ( 'returns true if there is a Git directory' , async ( ) => {
7575 await fs . mkdir ( path . join ( TEMP_DIR , '.git' ) )
7676
7777 const isCurrentRepositoryRoot = await isRepositoryRoot ( TEMP_DIR )
7878
79- expect ( isCurrentRepositoryRoot ) . to . be . true
79+ expect ( isCurrentRepositoryRoot ) . toBe ( true )
8080 } )
8181
8282 it ( 'returns false if there is a package.json without workspaces field' , async ( ) => {
@@ -91,7 +91,7 @@ describe('isRepositoryRoot', () => {
9191
9292 const isCurrentRepositoryRoot = await isRepositoryRoot ( TEMP_DIR )
9393
94- expect ( isCurrentRepositoryRoot ) . to . be . false
94+ expect ( isCurrentRepositoryRoot ) . toBe ( false )
9595 } )
9696
9797 it ( 'returns true if there is a package.json with workspaces field' , async ( ) => {
@@ -109,7 +109,7 @@ describe('isRepositoryRoot', () => {
109109
110110 const isCurrentRepositoryRoot = await isRepositoryRoot ( TEMP_DIR )
111111
112- expect ( isCurrentRepositoryRoot ) . to . be . true
112+ expect ( isCurrentRepositoryRoot ) . toBe ( true )
113113 } )
114114} )
115115
@@ -119,24 +119,24 @@ describe('detectThirdPartyCTFrameworks', () => {
119119
120120 const thirdPartyFrameworks = await detectThirdPartyCTFrameworks ( projectRoot )
121121
122- expect ( thirdPartyFrameworks . frameworks [ 0 ] . type ) . eq ( 'cypress-ct-qwik' )
122+ expect ( thirdPartyFrameworks . frameworks [ 0 ] . type ) . toEqual ( 'cypress-ct-qwik' )
123123 } )
124124
125125 it ( 'detects third party frameworks in org namespace' , async ( ) => {
126126 const projectRoot = await scaffoldQwikApp ( [ '@org/cypress-ct-qwik' ] )
127127
128128 const thirdPartyFrameworks = await detectThirdPartyCTFrameworks ( projectRoot )
129129
130- expect ( thirdPartyFrameworks . frameworks [ 0 ] . type ) . eq ( '@org/cypress-ct-qwik' )
130+ expect ( thirdPartyFrameworks . frameworks [ 0 ] . type ) . toEqual ( '@org/cypress-ct-qwik' )
131131 } )
132132
133133 it ( 'ignores misconfigured third party frameworks' , async ( ) => {
134134 const projectRoot = await scaffoldQwikApp ( [ 'cypress-ct-qwik' , 'misconfigured-cypress-ct-qwik' ] )
135135
136136 const thirdPartyFrameworks = await detectThirdPartyCTFrameworks ( projectRoot )
137137
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' )
140140 } )
141141
142142 it ( 'detects third party frameworks in monorepos with hoisted dependencies' , async ( ) => {
@@ -150,19 +150,19 @@ describe('detectThirdPartyCTFrameworks', () => {
150150 // Look for third-party modules in packages/foo (where Cypress was launched from)
151151 const thirdPartyFrameworks = await detectThirdPartyCTFrameworks ( projectRoot )
152152
153- expect ( thirdPartyFrameworks . frameworks [ 0 ] . type ) . eq ( 'cypress-ct-qwik' )
153+ expect ( thirdPartyFrameworks . frameworks [ 0 ] . type ) . toEqual ( 'cypress-ct-qwik' )
154154 } )
155155
156156 it ( 'validates third party module' , ( ) => {
157- expect ( ( ) => validateThirdPartyModule ( solidJs ) ) . to . not . throw ( )
157+ expect ( ( ) => validateThirdPartyModule ( solidJs ) ) . not . toThrow ( )
158158
159159 const gen = ( m : any ) => m
160160
161- expect ( ( ) => validateThirdPartyModule ( gen ( { ...solidJs , type : 'misconfigured' } ) ) ) . to . throw ( )
161+ expect ( ( ) => validateThirdPartyModule ( gen ( { ...solidJs , type : 'misconfigured' } ) ) ) . toThrow ( )
162162 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 ( )
167167 } )
168168} )
0 commit comments