Skip to content

Commit 4e47c21

Browse files
committed
fix: clean up tests and tsconfig
1 parent 22231bf commit 4e47c21

File tree

6 files changed

+31
-15
lines changed

6 files changed

+31
-15
lines changed

test/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
"license": "ISC",
1212
"devDependencies": {
1313
"@types/jest": "^26.0.20",
14+
"@types/node-fetch": "^2.5.8",
1415
"@types/supertest": "^2.0.10",
1516
"jest": "^26.6.3",
17+
"node-fetch": "^2.6.1",
1618
"supertest": "^6.1.1",
1719
"ts-jest": "^26.4.4",
1820
"typescript": "^4.1.3"

test/plugin.test.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { logger } from "@coder/logger"
2-
import * as assert from "assert"
32
import * as express from "express"
43
import * as fs from "fs"
54
import * as path from "path"
@@ -15,7 +14,7 @@ describe("plugin", () => {
1514
let papi: PluginAPI
1615
let s: httpserver.HttpServer
1716

18-
before(async () => {
17+
beforeAll(async () => {
1918
papi = new PluginAPI(logger, `${path.resolve(__dirname, "test-plugin")}:meow`)
2019
await papi.loadPlugins()
2120

@@ -27,16 +26,16 @@ describe("plugin", () => {
2726
await s.listen(app)
2827
})
2928

30-
after(async () => {
29+
afterAll(async () => {
3130
await s.close()
3231
})
3332

3433
it("/api/applications", async () => {
3534
const resp = await s.fetch("/api/applications")
36-
assert.equal(200, resp.status)
35+
expect(resp.status).toBe(200)
3736
const body = await resp.json()
3837
logger.debug(`${JSON.stringify(body)}`)
39-
assert.deepEqual(body, [
38+
expect(body).toBe([
4039
{
4140
name: "Test App",
4241
version: "4.0.0",
@@ -65,8 +64,8 @@ describe("plugin", () => {
6564
encoding: "utf8",
6665
})
6766
const resp = await s.fetch("/test-plugin/test-app")
68-
assert.equal(200, resp.status)
67+
expect(resp.status).toBe(200)
6968
const body = await resp.text()
70-
assert.equal(body, indexHTML)
69+
expect(body).toBe(indexHTML)
7170
})
7271
})

test/proxy.test.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as assert from "assert"
21
import * as express from "express"
32
import * as httpserver from "./httpserver"
43
import * as integration from "./integration"
@@ -8,7 +7,7 @@ describe("proxy", () => {
87
const nhooyrDevServer = new httpserver.HttpServer()
98
let proxyPath: string
109

11-
before(async () => {
10+
beforeAll(async () => {
1211
const e = express.default()
1312
await nhooyrDevServer.listen(e)
1413
e.get("/wsup", (req, res) => {
@@ -20,7 +19,7 @@ describe("proxy", () => {
2019
})
2120
})
2221

23-
after(async () => {
22+
afterAll(async () => {
2423
await nhooyrDevServer.close()
2524
})
2625

@@ -34,14 +33,16 @@ describe("proxy", () => {
3433
it("should rewrite the base path", async () => {
3534
;[, , codeServer] = await integration.setup(["--auth=none"], "")
3635
const resp = await codeServer.fetch(proxyPath)
37-
assert.equal(resp.status, 200)
38-
assert.equal(await resp.json(), "asher is the best")
36+
expect(resp.status).toBe(200)
37+
const json = await resp.json()
38+
expect(json).toBe("asher is the best")
3939
})
4040

4141
it("should not rewrite the base path", async () => {
4242
;[, , codeServer] = await integration.setup(["--auth=none", "--proxy-path-passthrough=true"], "")
4343
const resp = await codeServer.fetch(proxyPath)
44-
assert.equal(resp.status, 200)
45-
assert.equal(await resp.json(), "joe is the best")
44+
expect(resp.status).toBe(200)
45+
const json = await resp.json()
46+
expect(json).toBe("joe is the best")
4647
})
4748
})

test/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"typeRoots": [
55
"node_modules/@types"
66
],
7+
"composite": true
78
},
89
"include": ["./**/*.ts"],
910
"exclude": ["node_modules/**"],

test/yarn.lock

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,14 @@
551551
jest-diff "^26.0.0"
552552
pretty-format "^26.0.0"
553553

554+
"@types/node-fetch@^2.5.8":
555+
version "2.5.8"
556+
resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.5.8.tgz#e199c835d234c7eb0846f6618012e558544ee2fb"
557+
integrity sha512-fbjI6ja0N5ZA8TV53RUqzsKNkl9fv8Oj3T7zxW7FGv1GSH7gwJaNF8dzCjrqKaxKeUpTz4yT1DaJFq/omNpGfw==
558+
dependencies:
559+
"@types/node" "*"
560+
form-data "^3.0.0"
561+
554562
"@types/node@*":
555563
version "14.14.22"
556564
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.22.tgz#0d29f382472c4ccf3bd96ff0ce47daf5b7b84b18"
@@ -2578,6 +2586,11 @@ nice-try@^1.0.4:
25782586
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"
25792587
integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==
25802588

2589+
node-fetch@^2.6.1:
2590+
version "2.6.1"
2591+
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052"
2592+
integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==
2593+
25812594
node-int64@^0.4.0:
25822595
version "0.4.0"
25832596
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@
2020
"downlevelIteration": true
2121
},
2222
"include": ["./src/**/*.ts"],
23-
"exclude": ["./test"]
23+
"exclude": "test"
2424
}

0 commit comments

Comments
 (0)