@@ -4,8 +4,7 @@ import { join, resolve } from 'node:path';
44import { fileURLToPath } from 'node:url' ;
55
66import prettier from 'prettier' ;
7- import { test } from 'uvu' ;
8- import * as assert from 'uvu/assert' ;
7+ import { test , expect } from 'vitest' ;
98
109import { build , watch } from '../src/index.js' ;
1110import { load_config } from '../src/config.js' ;
@@ -40,13 +39,13 @@ async function test_make_package(path, options) {
4039 const expected_files = walk ( ewd , true ) ;
4140 const actual_files = walk ( output , true ) ;
4241
43- assert . equal ( actual_files , expected_files ) ;
42+ expect ( actual_files ) . toEqual ( expected_files ) ;
4443
4544 const extensions = [ '.json' , '.svelte' , '.ts' , 'js' , '.map' ] ;
4645 for ( const file of actual_files ) {
4746 const pathname = join ( output , file ) ;
4847 if ( fs . statSync ( pathname ) . isDirectory ( ) ) continue ;
49- assert . ok ( expected_files . includes ( file ) , `Did not expect ${ file } in ${ path } ` ) ;
48+ expect ( expected_files . includes ( file ) , `Did not expect ${ file } in ${ path } ` ) . toBeTruthy ( ) ;
5049
5150 const expected = fs . readFileSync ( join ( ewd , file ) ) ;
5251 const actual = fs . readFileSync ( join ( output , file ) ) ;
@@ -55,9 +54,9 @@ async function test_make_package(path, options) {
5554 if ( extensions . some ( ( ext ) => pathname . endsWith ( ext ) ) ) {
5655 const expected_content = await format ( file , expected . toString ( 'utf-8' ) ) ;
5756 const actual_content = await format ( file , actual . toString ( 'utf-8' ) ) ;
58- assert . fixture ( actual_content , expected_content , err_msg ) ;
57+ expect ( actual_content , err_msg ) . toBe ( expected_content ) ;
5958 } else {
60- assert . ok ( expected . equals ( actual ) , err_msg ) ;
59+ expect ( expected . equals ( actual ) ) . toBeTruthy ( ) ;
6160 }
6261 }
6362}
@@ -95,25 +94,24 @@ for (const dir of fs.readdirSync(join(__dirname, 'errors'))) {
9594
9695 try {
9796 await build ( { cwd, input, output, types : true , config } ) ;
98- assert . unreachable ( 'Must not pass build' ) ;
97+ throw new Error ( 'Must not pass build' ) ;
9998 } catch ( /** @type {any } */ error ) {
100- assert . instance ( error , Error ) ;
99+ expect ( error ) . toBeInstanceOf ( Error ) ;
101100 switch ( dir ) {
102101 case 'no-lib-folder' :
103- assert . match (
104- error . message . replace ( / \\ / g, '/' ) ,
102+ expect ( error . message . replace ( / \\ / g, '/' ) ) . toMatch (
105103 'test/errors/no-lib-folder/src/lib does not exist'
106104 ) ;
107105 break ;
108106 // TODO: non-existent tsconfig passes without error
109107 // it detects tsconfig in packages/kit instead and creates package folder
110108 // in packages/kit/package, not sure how to handle and test this yet
111109 // case 'no-tsconfig':
112- // assert.match (error.message, 'Failed to locate tsconfig or jsconfig');
110+ // expect (error.message).toMatch( 'Failed to locate tsconfig or jsconfig');
113111 // break;
114112
115113 default :
116- assert . unreachable ( 'All error test must be handled' ) ;
114+ throw new Error ( 'All error test must be handled' ) ;
117115 break ;
118116 }
119117 } finally {
@@ -191,7 +189,7 @@ if (!process.env.CI) {
191189
192190 /** @param {string } file */
193191 function compare ( file ) {
194- assert . equal ( read ( `package/${ file } ` ) , read ( `expected/${ file } ` ) ) ;
192+ expect ( read ( `package/${ file } ` ) ) . toEqual ( read ( `expected/${ file } ` ) ) ;
195193 }
196194
197195 /** @param {string } file */
@@ -253,19 +251,18 @@ if (!process.env.CI) {
253251 remove ( 'src/lib/b.ts' ) ;
254252 remove ( 'src/lib/post-error.svelte' ) ;
255253 }
256- } ) ;
254+ } , 30_000 ) ;
257255}
258256
259257/**
260258 * @param {string[] } actual
261259 * @param {string[] } expected
262260 */
263261function has_warnings ( actual , expected ) {
264- assert . equal ( actual . length , expected . length ) ;
265- assert . equal (
266- actual . filter ( ( warning ) => expected . some ( ( str ) => warning . startsWith ( str ) ) ) . length ,
267- expected . length
268- ) ;
262+ expect ( actual . length ) . toEqual ( expected . length ) ;
263+ expect (
264+ actual . filter ( ( warning ) => expected . some ( ( str ) => warning . startsWith ( str ) ) ) . length
265+ ) . toEqual ( expected . length ) ;
269266}
270267
271268test ( 'validates package (1)' , ( ) => {
@@ -320,7 +317,7 @@ test('validates package (all ok 1)', () => {
320317 peerDependencies : { svelte : '^3.55.0' }
321318 } ) ;
322319
323- assert . equal ( warnings . length , 0 ) ;
320+ expect ( warnings . length ) . toEqual ( 0 ) ;
324321} ) ;
325322
326323test ( 'validates package (all ok 2)' , ( ) => {
@@ -338,7 +335,5 @@ test('validates package (all ok 2)', () => {
338335 svelte : './dist/C.svelte'
339336 } ) ;
340337
341- assert . equal ( warnings . length , 0 ) ;
338+ expect ( warnings . length ) . toEqual ( 0 ) ;
342339} ) ;
343-
344- test . run ( ) ;
0 commit comments