1
0
Fork 0
mirror of https://github.com/kou029w/_.git synced 2025-01-30 22:08:02 +00:00

create node-test

This commit is contained in:
Nebel 2022-08-19 23:19:11 +09:00
parent 4302d439b9
commit 542bcbf4dd
5 changed files with 31 additions and 0 deletions

6
node-test/equal.test.js Normal file
View file

@ -0,0 +1,6 @@
import { test } from "node:test";
import assert from "node:assert/strict";
test("1 + 2 = 3", () => {
assert.equal(1 + 2, 3);
});

1
node-test/hello.js Normal file
View file

@ -0,0 +1 @@
export default "hello!";

7
node-test/hello.test.js Normal file
View file

@ -0,0 +1,7 @@
import { test } from "node:test";
import assert from "node:assert/strict";
import message from "./hello.js";
test("say hello", () => {
assert.equal(message, "hello!");
});

9
node-test/package.json Normal file
View file

@ -0,0 +1,9 @@
{
"type": "module",
"scripts": {
"test": "node --test"
},
"engines": {
"node": "^18.7.0"
}
}

View file

@ -0,0 +1,8 @@
import { test } from "node:test";
import assert from "node:assert/strict";
test("parse json", () => {
const json = `{"name": "太郎", "age": 42}`;
const obj = JSON.parse(json);
assert.deepEqual(obj, { name: "太郎", age: 42 });
});