Skip to content

Commit 883dd13

Browse files
committed
refactor: move jest and add package.json to /test
1 parent 646ee3a commit 883dd13

File tree

12 files changed

+3859
-1824
lines changed

12 files changed

+3859
-1824
lines changed

ci/dev/test.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ main() {
66

77
cd test/test-plugin
88
make -s out/index.js
9-
cd "$OLDPWD"
10-
yarn jest "$@"
9+
cd "$OLDPWD/test"
10+
yarn
11+
yarn test "$@"
1112
}
1213

1314
main "$@"

lib/vscode/build/tsconfig.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
"strict": true,
1616
"noUnusedLocals": true,
1717
"noUnusedParameters": true,
18-
"newLine": "lf",
19-
"skipLibCheck": true
18+
"newLine": "lf"
2019
},
2120
"include": [
2221
"**/*.ts"

lib/vscode/extensions/typescript-language-features/src/utils/platform.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
import * as vscode from 'vscode';
77

88
export function isWeb(): boolean {
9-
// NOTE@coder: Remove unused ts-expect-error directive which causes tsc to error.
9+
// @ts-expect-error
1010
return typeof navigator !== 'undefined' && vscode.env.uiKind === vscode.UIKind.Web;
1111
}

package.json

-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"@types/express": "^4.17.8",
3636
"@types/fs-extra": "^8.0.1",
3737
"@types/http-proxy": "^1.17.4",
38-
"@types/jest": "^26.0.20",
3938
"@types/js-yaml": "^3.12.3",
4039
"@types/node": "^12.12.7",
4140
"@types/node-fetch": "^2.5.7",
@@ -55,7 +54,6 @@
5554
"eslint-config-prettier": "^6.0.0",
5655
"eslint-plugin-import": "^2.18.2",
5756
"eslint-plugin-prettier": "^3.1.0",
58-
"jest": "^26.6.3",
5957
"leaked-handles": "^5.2.0",
6058
"parcel-bundler": "^1.12.4",
6159
"prettier": "^2.0.5",
File renamed without changes.

test/package.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "test",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "jest"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "ISC",
12+
"devDependencies": {
13+
"@types/jest": "^26.0.20",
14+
"@types/node-fetch": "^2.5.8",
15+
"@types/supertest": "^2.0.10",
16+
"jest": "^26.6.3",
17+
"node-fetch": "^2.6.1",
18+
"supertest": "^6.1.1",
19+
"ts-jest": "^26.4.4",
20+
"typescript": "^4.1.3"
21+
}
22+
}

test/plugin.test.ts

+6-7
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).toStrictEqual([
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

+8-7
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

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{
22
"extends": "../tsconfig.json",
3-
"include": ["./**/*.ts"]
3+
"compilerOptions": {
4+
"typeRoots": ["node_modules/@types", "../typings"],
5+
"composite": true
6+
},
7+
"include": ["./**/*.ts"],
8+
"exclude": ["node_modules/**"],
9+
"types": ["jest"]
410
}

0 commit comments

Comments
 (0)