Skip to content

Commit 282b7e8

Browse files
authored
chore: friendly initial test in asinit (#2955)
1 parent 8257b1c commit 282b7e8

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

NOTICE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ under the licensing terms detailed in LICENSE:
6060
* Fabián Heredia Montiel <[email protected]>
6161
* Jonas Minnberg <[email protected]>
6262
* Kam Chehresa <[email protected]>
63+
* Mopsgamer <[email protected]>
6364

6465
Portions of this software are derived from third-party works licensed under
6566
the following terms:

bin/asinit.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ if (/^(\.\.[/\\])*node_modules[/\\]assemblyscript[/\\]/.test(tsconfigBase)) {
100100
}
101101
const entryFile = path.join(assemblyDir, "index.ts");
102102
const buildDir = path.join(projectDir, "build");
103-
const testsDir = path.join(projectDir, "tests");
103+
const testsDir = path.join(projectDir, "test");
104104
const gitignoreFile = path.join(buildDir, ".gitignore");
105105
const packageFile = path.join(projectDir, "package.json");
106106

@@ -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",
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";
394394
pkg["scripts"] = scripts;
395395
updated = true;
396396
}
@@ -416,7 +416,7 @@ function ensurePackageJson() {
416416
}
417417

418418
function ensureTestsDirectory() {
419-
console.log("- Making sure that the 'tests' directory exists...");
419+
console.log("- Making sure that the 'test' directory exists...");
420420
if (!fs.existsSync(testsDir)) {
421421
fs.mkdirSync(testsDir);
422422
console.log(stdoutColors.green(" Created: ") + testsDir);
@@ -427,13 +427,16 @@ function ensureTestsDirectory() {
427427
}
428428

429429
function ensureTestsIndexJs() {
430-
console.log("- Making sure that 'tests/index.js' exists...");
430+
console.log("- Making sure that 'test/index.js' exists...");
431431
if (!fs.existsSync(testsIndexFile)) {
432432
fs.writeFileSync(testsIndexFile, [
433-
"import assert from \"assert\";",
433+
"import assert from \"node:assert/strict\";",
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.equal(add(1, 2), 3);",
439+
"});"
437440
].join("\n") + "\n");
438441
console.log(stdoutColors.green(" Created: ") + testsIndexFile);
439442
} else {

0 commit comments

Comments
 (0)