From 32bc4cf28e789b5987217285a9b0831f5829d2ad Mon Sep 17 00:00:00 2001 From: Mopsgamer <79159094+Mopsgamer@users.noreply.github.com> Date: Sat, 25 Oct 2025 15:03:43 +0200 Subject: [PATCH 1/5] impr(init): create correct tests --- bin/asinit.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/bin/asinit.js b/bin/asinit.js index 6950a2341a..78ae2d2428 100755 --- a/bin/asinit.js +++ b/bin/asinit.js @@ -105,7 +105,7 @@ const gitignoreFile = path.join(buildDir, ".gitignore"); const packageFile = path.join(projectDir, "package.json"); const indexHtmlFile = path.join(projectDir, "index.html"); -const testsIndexFile = path.join(testsDir, "index.js"); +const testsIndexFile = path.join(testsDir, "index.test.js"); const paths = [ [assemblyDir, "Directory holding the AssemblyScript sources being compiled to WebAssembly."], @@ -358,7 +358,7 @@ function ensurePackageJson() { "asbuild:debug": buildDebug, "asbuild:release": buildRelease, "asbuild": buildAll, - "test": "node tests", + "test": "node --test tests/**/*", "start": "npx serve ." }, "devDependencies": { @@ -390,7 +390,7 @@ function ensurePackageJson() { updated = true; } if (!scripts["test"] || scripts["test"] == npmDefaultTest) { - scripts["test"] = "node tests"; + scripts["test"] = "node --test tests/**/*"; pkg["scripts"] = scripts; updated = true; } @@ -427,13 +427,16 @@ function ensureTestsDirectory() { } function ensureTestsIndexJs() { - console.log("- Making sure that 'tests/index.js' exists..."); + console.log("- Making sure that 'tests/index.test.js' exists..."); if (!fs.existsSync(testsIndexFile)) { fs.writeFileSync(testsIndexFile, [ - "import assert from \"assert\";", + "import assert from \"node:assert\";", + "import { it } from \"node:test\";", "import { add } from \"../build/debug.js\";", - "assert.strictEqual(add(1, 2), 3);", - "console.log(\"ok\");" + "", + "it(\"add\", () => {", + " assert.strictEqual(add(1, 2), 3);", + "});" ].join("\n") + "\n"); console.log(stdoutColors.green(" Created: ") + testsIndexFile); } else { From 3b841ff51edc1dd195518f20a9690e0f391148a7 Mon Sep 17 00:00:00 2001 From: Mopsgamer <79159094+Mopsgamer@users.noreply.github.com> Date: Sat, 25 Oct 2025 15:05:11 +0200 Subject: [PATCH 2/5] chore: notice myself --- NOTICE | 1 + 1 file changed, 1 insertion(+) diff --git a/NOTICE b/NOTICE index e7a2601827..6dc4400b82 100644 --- a/NOTICE +++ b/NOTICE @@ -60,6 +60,7 @@ under the licensing terms detailed in LICENSE: * Fabián Heredia Montiel * Jonas Minnberg * Kam Chehresa +* Mopsgamer <79159094+Mopsgamer@users.noreply.github.com> Portions of this software are derived from third-party works licensed under the following terms: From b5cacdfb1baa63563463c24a4effe294b5ca65fb Mon Sep 17 00:00:00 2001 From: Mopsgamer <79159094+Mopsgamer@users.noreply.github.com> Date: Sat, 25 Oct 2025 15:06:00 +0200 Subject: [PATCH 3/5] rename the folder --- bin/asinit.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/asinit.js b/bin/asinit.js index 78ae2d2428..3bafaa64b1 100755 --- a/bin/asinit.js +++ b/bin/asinit.js @@ -100,7 +100,7 @@ if (/^(\.\.[/\\])*node_modules[/\\]assemblyscript[/\\]/.test(tsconfigBase)) { } const entryFile = path.join(assemblyDir, "index.ts"); const buildDir = path.join(projectDir, "build"); -const testsDir = path.join(projectDir, "tests"); +const testsDir = path.join(projectDir, "test"); const gitignoreFile = path.join(buildDir, ".gitignore"); const packageFile = path.join(projectDir, "package.json"); @@ -358,7 +358,7 @@ function ensurePackageJson() { "asbuild:debug": buildDebug, "asbuild:release": buildRelease, "asbuild": buildAll, - "test": "node --test tests/**/*", + "test": "node --test", "start": "npx serve ." }, "devDependencies": { @@ -390,7 +390,7 @@ function ensurePackageJson() { updated = true; } if (!scripts["test"] || scripts["test"] == npmDefaultTest) { - scripts["test"] = "node --test tests/**/*"; + scripts["test"] = "node --test"; pkg["scripts"] = scripts; updated = true; } @@ -416,7 +416,7 @@ function ensurePackageJson() { } function ensureTestsDirectory() { - console.log("- Making sure that the 'tests' directory exists..."); + console.log("- Making sure that the 'test' directory exists..."); if (!fs.existsSync(testsDir)) { fs.mkdirSync(testsDir); console.log(stdoutColors.green(" Created: ") + testsDir); @@ -427,7 +427,7 @@ function ensureTestsDirectory() { } function ensureTestsIndexJs() { - console.log("- Making sure that 'tests/index.test.js' exists..."); + console.log("- Making sure that 'test/index.test.js' exists..."); if (!fs.existsSync(testsIndexFile)) { fs.writeFileSync(testsIndexFile, [ "import assert from \"node:assert\";", From a96d01755a53eb7fff896aada0efebb88f7c1302 Mon Sep 17 00:00:00 2001 From: Mopsgamer <79159094+Mopsgamer@users.noreply.github.com> Date: Sat, 25 Oct 2025 15:06:12 +0200 Subject: [PATCH 4/5] rename index.test.js to index.js --- bin/asinit.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/asinit.js b/bin/asinit.js index 3bafaa64b1..a19b6e0b58 100755 --- a/bin/asinit.js +++ b/bin/asinit.js @@ -105,7 +105,7 @@ const gitignoreFile = path.join(buildDir, ".gitignore"); const packageFile = path.join(projectDir, "package.json"); const indexHtmlFile = path.join(projectDir, "index.html"); -const testsIndexFile = path.join(testsDir, "index.test.js"); +const testsIndexFile = path.join(testsDir, "index.js"); const paths = [ [assemblyDir, "Directory holding the AssemblyScript sources being compiled to WebAssembly."], @@ -427,7 +427,7 @@ function ensureTestsDirectory() { } function ensureTestsIndexJs() { - console.log("- Making sure that 'test/index.test.js' exists..."); + console.log("- Making sure that 'test/index.js' exists..."); if (!fs.existsSync(testsIndexFile)) { fs.writeFileSync(testsIndexFile, [ "import assert from \"node:assert\";", From d410758118b241acedb69e2fa88fd789b8080b03 Mon Sep 17 00:00:00 2001 From: Mopsgamer <79159094+Mopsgamer@users.noreply.github.com> Date: Sat, 25 Oct 2025 15:06:25 +0200 Subject: [PATCH 5/5] use assert/strict --- bin/asinit.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/asinit.js b/bin/asinit.js index a19b6e0b58..cb52aad48c 100755 --- a/bin/asinit.js +++ b/bin/asinit.js @@ -430,12 +430,12 @@ function ensureTestsIndexJs() { console.log("- Making sure that 'test/index.js' exists..."); if (!fs.existsSync(testsIndexFile)) { fs.writeFileSync(testsIndexFile, [ - "import assert from \"node:assert\";", + "import assert from \"node:assert/strict\";", "import { it } from \"node:test\";", "import { add } from \"../build/debug.js\";", "", "it(\"add\", () => {", - " assert.strictEqual(add(1, 2), 3);", + " assert.equal(add(1, 2), 3);", "});" ].join("\n") + "\n"); console.log(stdoutColors.green(" Created: ") + testsIndexFile);