Skip to content
This repository was archived by the owner on Jun 19, 2025. It is now read-only.

Commit 7de4556

Browse files
committed
chore(test): migrate from tape to test_runner
1 parent c5d0077 commit 7de4556

File tree

3 files changed

+39
-62
lines changed

3 files changed

+39
-62
lines changed

package.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"type": "module",
77
"scripts": {
88
"prepublishOnly": "pkg-ok",
9-
"test": "cross-env esm-tape-runner 'test/**/*.spec.js' | tap-monkey",
9+
"test": "node -r dotenv --test",
1010
"coverage": "c8 -r html npm test"
1111
},
1212
"repository": {
@@ -35,14 +35,10 @@
3535
"devDependencies": {
3636
"@nodesecure/eslint-config": "^1.5.0",
3737
"@slimio/is": "^2.0.0",
38-
"@small-tech/esm-tape-runner": "^2.0.0",
39-
"@small-tech/tap-monkey": "^1.4.0",
4038
"c8": "^7.12.0",
41-
"cross-env": "^7.0.3",
4239
"dotenv": "^16.0.2",
4340
"eslint": "^8.23.0",
44-
"pkg-ok": "^3.0.0",
45-
"tape": "^5.6.0"
41+
"pkg-ok": "^3.0.0"
4642
},
4743
"engines": {
4844
"node": ">=18"

test/test.spec.js

Lines changed: 30 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import dotenv from "dotenv";
2-
dotenv.config();
3-
41
// Import Node.js Dependencies
52
import { fileURLToPath } from "url";
63
import path from "path";
74
import fs from "fs/promises";
5+
import { test } from "node:test";
6+
import assert from "node:assert";
87

98
// Import Third-party Dependencies
10-
import test from "tape";
119
import is from "@slimio/is";
1210

1311
// Import Internal Dependency
@@ -19,65 +17,51 @@ const kDownloadDir = path.join(__dirname, "downloads");
1917

2018
await fs.mkdir(kDownloadDir);
2119

22-
test("gitlab.download should be an asyncFunction", (tape) => {
23-
tape.true(is.func(gitlab.download));
24-
tape.true(is.asyncFunction(gitlab.download));
25-
26-
tape.end();
20+
test("gitlab.download should be an asyncFunction", () => {
21+
assert.equal(is.func(gitlab.download), true);
22+
assert.equal(is.asyncFunction(gitlab.download), true);
2723
});
2824

29-
test("gitlab.downloadAndExtract should be an asyncFunction", (tape) => {
30-
tape.true(is.func(gitlab.downloadAndExtract));
31-
tape.true(is.asyncFunction(gitlab.downloadAndExtract));
32-
33-
tape.end();
25+
test("gitlab.downloadAndExtract should be an asyncFunction", () => {
26+
assert.equal(is.func(gitlab.downloadAndExtract), true);
27+
assert.equal(is.asyncFunction(gitlab.downloadAndExtract), true);
3428
});
3529

36-
test("download must throw: repository must be a string!", async(tape) => {
37-
tape.plan(2);
38-
39-
try {
40-
await gitlab.download(10);
41-
}
42-
catch (error) {
43-
tape.strictEqual(error.name, "TypeError");
44-
tape.strictEqual(error.message, "repository must be a string!");
45-
}
46-
47-
tape.end();
30+
test("download must throw: repository must be a string!", async() => {
31+
assert.rejects(
32+
async() => await gitlab.download(10),
33+
{
34+
name: "TypeError",
35+
message: "repository must be a string!"
36+
}
37+
);
4838
});
4939

50-
test("extract tar.gz at in the current working dir", async(tape) => {
40+
test("extract tar.gz at in the current working dir", async() => {
5141
const { location } = await gitlab.download("polychromatic.plombier-chauffagiste");
5242

5343
await fs.access(location);
54-
tape.strictEqual(path.extname(location), ".gz");
55-
56-
tape.end();
44+
assert.strictEqual(path.extname(location), ".gz");
5745
});
5846

59-
test("download and extract a public gitlab repository", async(tape) => {
47+
test("download and extract a public gitlab repository", async() => {
6048
const { location } = await gitlab.downloadAndExtract("polychromatic.plombier-chauffagiste", {
6149
dest: kDownloadDir
6250
});
6351

64-
await fs.access(location);
65-
tape.pass();
66-
67-
tape.end();
52+
await assert.doesNotReject(
53+
async() => await fs.access(location)
54+
);
6855
});
6956

70-
test("teardown", async(tape) => {
57+
test("teardown", async() => {
7158
await new Promise((resolve) => setImmediate(resolve));
72-
await fs.rm(kDownloadDir, { recursive: true, force: true });
7359

74-
try {
75-
await fs.unlink(path.join(process.cwd(), "plombier-chauffagiste-master.tar.gz"));
76-
}
77-
catch (err) {
78-
// do nothing
79-
}
80-
finally {
81-
tape.end();
82-
}
60+
await assert.doesNotReject(
61+
async() => await fs.rm(kDownloadDir, { recursive: true, force: true })
62+
);
63+
64+
await assert.doesNotReject(
65+
async() => await fs.unlink(path.join(process.cwd(), "plombier-chauffagiste-master.tar.gz"))
66+
);
8367
});

test/utils.spec.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
// Import Third-party Dependencies
2-
import test from "tape";
1+
// Import Node.js Dependencies
2+
import { test } from "node:test";
3+
import assert from "node:assert";
34

45
// Import Internal Dependency
56
import { getRepositoryPath } from "../src/utils.js";
67

7-
test("getRepositoryPath must return id", (tape) => {
8-
tape.is(getRepositoryPath("10"), "10");
9-
10-
tape.end();
8+
test("getRepositoryPath must return id", () => {
9+
assert.equal(getRepositoryPath("10"), "10");
1110
});
1211

13-
test("getRepositoryPath must return gitlab path", (tape) => {
14-
tape.is(getRepositoryPath("nodesecure.boo"), "nodesecure%2Fboo");
15-
16-
tape.end();
12+
test("getRepositoryPath must return gitlab path", () => {
13+
assert.equal(getRepositoryPath("nodesecure.boo"), "nodesecure%2Fboo");
1714
});

0 commit comments

Comments
 (0)