Skip to content

Commit

Permalink
test runner
Browse files Browse the repository at this point in the history
  • Loading branch information
ss49919201 committed Sep 1, 2024
1 parent 2edd92a commit af900d3
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
32 changes: 32 additions & 0 deletions typescript/test-runner/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import assert from "node:assert/strict";
import { test } from "node:test";

test("テストが成功する", async () => {
assert.strictEqual(1, 1);
});

const promise = new Promise((resolve) => {
resolve("ok");
});
test("await を使ったテストが成功する", async () => {
assert.strictEqual(await promise, "ok");
});

test("テストが失敗する", async () => {
assert.strictEqual(1, 2);
});

const promise2 = new Promise((_, reject) => {
reject(new Error("ng"));
});
test("await を使ったテストが失敗する", async () => {
await promise2;
});

test("falty な値を渡すとテストが成功する", (t, done) => {
done(false);
});

test("truty な値を渡すとテストが失敗する", (t, done) => {
done(true);
});
45 changes: 45 additions & 0 deletions typescript/test-runner/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions typescript/test-runner/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "test-runner",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "node --test index.test.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@types/node": "^22.5.1",
"typescript": "^5.5.4"
}
}

0 comments on commit af900d3

Please sign in to comment.