mirror of
https://github.com/kou029w/_.git
synced 2025-01-30 22:08:02 +00:00
create node-test
This commit is contained in:
parent
4302d439b9
commit
542bcbf4dd
5 changed files with 31 additions and 0 deletions
6
node-test/equal.test.js
Normal file
6
node-test/equal.test.js
Normal 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
1
node-test/hello.js
Normal file
|
@ -0,0 +1 @@
|
|||
export default "hello!";
|
7
node-test/hello.test.js
Normal file
7
node-test/hello.test.js
Normal 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
9
node-test/package.json
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "node --test"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.7.0"
|
||||
}
|
||||
}
|
8
node-test/parse-json.test.js
Normal file
8
node-test/parse-json.test.js
Normal 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 });
|
||||
});
|
Loading…
Add table
Reference in a new issue