refactor: move jest and add package.json to /test
This commit is contained in:
5
test/jest.config.js
Normal file
5
test/jest.config.js
Normal file
@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
preset: "ts-jest",
|
||||
testEnvironment: "node",
|
||||
testPathIgnorePatterns: ["/node_modules/", "lib/vscode/"],
|
||||
}
|
22
test/package.json
Normal file
22
test/package.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "test",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "jest"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.20",
|
||||
"@types/node-fetch": "^2.5.8",
|
||||
"@types/supertest": "^2.0.10",
|
||||
"jest": "^26.6.3",
|
||||
"node-fetch": "^2.6.1",
|
||||
"supertest": "^6.1.1",
|
||||
"ts-jest": "^26.4.4",
|
||||
"typescript": "^4.1.3"
|
||||
}
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
import { logger } from "@coder/logger"
|
||||
import * as assert from "assert"
|
||||
import * as express from "express"
|
||||
import * as fs from "fs"
|
||||
import * as path from "path"
|
||||
@ -15,7 +14,7 @@ describe("plugin", () => {
|
||||
let papi: PluginAPI
|
||||
let s: httpserver.HttpServer
|
||||
|
||||
before(async () => {
|
||||
beforeAll(async () => {
|
||||
papi = new PluginAPI(logger, `${path.resolve(__dirname, "test-plugin")}:meow`)
|
||||
await papi.loadPlugins()
|
||||
|
||||
@ -27,16 +26,16 @@ describe("plugin", () => {
|
||||
await s.listen(app)
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
afterAll(async () => {
|
||||
await s.close()
|
||||
})
|
||||
|
||||
it("/api/applications", async () => {
|
||||
const resp = await s.fetch("/api/applications")
|
||||
assert.equal(200, resp.status)
|
||||
expect(resp.status).toBe(200)
|
||||
const body = await resp.json()
|
||||
logger.debug(`${JSON.stringify(body)}`)
|
||||
assert.deepEqual(body, [
|
||||
expect(body).toStrictEqual([
|
||||
{
|
||||
name: "Test App",
|
||||
version: "4.0.0",
|
||||
@ -65,8 +64,8 @@ describe("plugin", () => {
|
||||
encoding: "utf8",
|
||||
})
|
||||
const resp = await s.fetch("/test-plugin/test-app")
|
||||
assert.equal(200, resp.status)
|
||||
expect(resp.status).toBe(200)
|
||||
const body = await resp.text()
|
||||
assert.equal(body, indexHTML)
|
||||
expect(body).toBe(indexHTML)
|
||||
})
|
||||
})
|
||||
|
@ -1,4 +1,3 @@
|
||||
import * as assert from "assert"
|
||||
import * as express from "express"
|
||||
import * as httpserver from "./httpserver"
|
||||
import * as integration from "./integration"
|
||||
@ -8,7 +7,7 @@ describe("proxy", () => {
|
||||
const nhooyrDevServer = new httpserver.HttpServer()
|
||||
let proxyPath: string
|
||||
|
||||
before(async () => {
|
||||
beforeAll(async () => {
|
||||
const e = express.default()
|
||||
await nhooyrDevServer.listen(e)
|
||||
e.get("/wsup", (req, res) => {
|
||||
@ -20,7 +19,7 @@ describe("proxy", () => {
|
||||
})
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
afterAll(async () => {
|
||||
await nhooyrDevServer.close()
|
||||
})
|
||||
|
||||
@ -34,14 +33,16 @@ describe("proxy", () => {
|
||||
it("should rewrite the base path", async () => {
|
||||
;[, , codeServer] = await integration.setup(["--auth=none"], "")
|
||||
const resp = await codeServer.fetch(proxyPath)
|
||||
assert.equal(resp.status, 200)
|
||||
assert.equal(await resp.json(), "asher is the best")
|
||||
expect(resp.status).toBe(200)
|
||||
const json = await resp.json()
|
||||
expect(json).toBe("asher is the best")
|
||||
})
|
||||
|
||||
it("should not rewrite the base path", async () => {
|
||||
;[, , codeServer] = await integration.setup(["--auth=none", "--proxy-path-passthrough=true"], "")
|
||||
const resp = await codeServer.fetch(proxyPath)
|
||||
assert.equal(resp.status, 200)
|
||||
assert.equal(await resp.json(), "joe is the best")
|
||||
expect(resp.status).toBe(200)
|
||||
const json = await resp.json()
|
||||
expect(json).toBe("joe is the best")
|
||||
})
|
||||
})
|
||||
|
@ -1,4 +1,10 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"include": ["./**/*.ts"]
|
||||
"compilerOptions": {
|
||||
"typeRoots": ["node_modules/@types", "../typings"],
|
||||
"composite": true
|
||||
},
|
||||
"include": ["./**/*.ts"],
|
||||
"exclude": ["node_modules/**"],
|
||||
"types": ["jest"]
|
||||
}
|
||||
|
3760
test/yarn.lock
Normal file
3760
test/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user