@@ -105,7 +105,7 @@ const gitignoreFile = path.join(buildDir, ".gitignore");
105105const packageFile = path . join ( projectDir , "package.json" ) ;
106106
107107const indexHtmlFile = path . join ( projectDir , "index.html" ) ;
108- const testsIndexFile = path . join ( testsDir , "index.js" ) ;
108+ const testsIndexFile = path . join ( testsDir , "index.test. js" ) ;
109109
110110const paths = [
111111 [ assemblyDir , "Directory holding the AssemblyScript sources being compiled to WebAssembly." ] ,
@@ -358,7 +358,7 @@ function ensurePackageJson() {
358358 "asbuild:debug" : buildDebug ,
359359 "asbuild:release" : buildRelease ,
360360 "asbuild" : buildAll ,
361- "test" : "node tests" ,
361+ "test" : "node --test tests/**/* " ,
362362 "start" : "npx serve ."
363363 } ,
364364 "devDependencies" : {
@@ -390,7 +390,7 @@ function ensurePackageJson() {
390390 updated = true ;
391391 }
392392 if ( ! scripts [ "test" ] || scripts [ "test" ] == npmDefaultTest ) {
393- scripts [ "test" ] = "node tests" ;
393+ scripts [ "test" ] = "node --test tests/**/* " ;
394394 pkg [ "scripts" ] = scripts ;
395395 updated = true ;
396396 }
@@ -427,13 +427,16 @@ function ensureTestsDirectory() {
427427}
428428
429429function ensureTestsIndexJs ( ) {
430- console . log ( "- Making sure that 'tests/index.js' exists..." ) ;
430+ console . log ( "- Making sure that 'tests/index.test. js' exists..." ) ;
431431 if ( ! fs . existsSync ( testsIndexFile ) ) {
432432 fs . writeFileSync ( testsIndexFile , [
433- "import assert from \"assert\";" ,
433+ "import assert from \"node:assert\";" ,
434+ "import { it } from \"node:test\";" ,
434435 "import { add } from \"../build/debug.js\";" ,
435- "assert.strictEqual(add(1, 2), 3);" ,
436- "console.log(\"ok\");"
436+ "" ,
437+ "it(\"add\", () => {" ,
438+ " assert.strictEqual(add(1, 2), 3);" ,
439+ "});"
437440 ] . join ( "\n" ) + "\n" ) ;
438441 console . log ( stdoutColors . green ( " Created: " ) + testsIndexFile ) ;
439442 } else {
0 commit comments