diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c861a808..914ad567 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -27,7 +27,15 @@ jobs: with: args: ./ci/steps/lint.sh - test: + test-unit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Run unit tests + uses: ./ci/images/debian10 + with: + args: ./ci/steps/test-unit.sh + test-e2e: needs: linux-amd64 runs-on: ubuntu-latest env: @@ -44,19 +52,19 @@ jobs: run: | cd release-packages && tar -xzf code-server*-linux-amd64.tar.gz - uses: microsoft/playwright-github-action@v1 - - name: Install dependencies and run tests + - name: Install dependencies and run end-to-end tests run: | ./release-packages/code-server*-linux-amd64/bin/code-server --home $CODE_SERVER_ADDRESS/healthz & yarn --frozen-lockfile - yarn test + yarn test:e2e - name: Upload test artifacts if: always() uses: actions/upload-artifact@v2 with: name: test-videos - path: ./test/videos + path: ./test/e2e/videos - name: Remove release packages and test artifacts - run: rm -rf ./release-packages ./test/videos + run: rm -rf ./release-packages ./test/e2e/videos release: runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index e49888f4..45da9b42 100644 --- a/.gitignore +++ b/.gitignore @@ -16,5 +16,5 @@ node-* .home coverage **/.DS_Store -test/videos -test/screenshots +test/e2e/videos +test/e2e/screenshots diff --git a/ci/README.md b/ci/README.md index 0bb983ef..19d6778e 100644 --- a/ci/README.md +++ b/ci/README.md @@ -52,7 +52,7 @@ Make sure you have `$GITHUB_TOKEN` set and [hub](https://github.com/github/hub) Currently, we run a command to manually generate the code coverage shield. Follow these steps: -1. Run `yarn test` and make sure all the tests are passing +1. Run `yarn test:unit` and make sure all the tests are passing 2. Run `yarn badges` 3. Go into the README and change the color from `red` to `green` in this line: @@ -72,8 +72,10 @@ This directory contains scripts used for the development of code-server. - Runs formatters. - [./ci/dev/lint.sh](./dev/lint.sh) (`yarn lint`) - Runs linters. -- [./ci/dev/test.sh](./dev/test.sh) (`yarn test`) - - Runs tests. +- [./ci/dev/test-unit.sh](./dev/test-unit.sh) (`yarn test:unit`) + - Runs unit tests. +- [./ci/dev/test-e2e.sh](./dev/test-e2e.sh) (`yarn test:e2e`) + - Runs end-to-end tests. - [./ci/dev/ci.sh](./dev/ci.sh) (`yarn ci`) - Runs `yarn fmt`, `yarn lint` and `yarn test`. - [./ci/dev/watch.ts](./dev/watch.ts) (`yarn watch`) @@ -142,11 +144,13 @@ This directory contains the scripts used in CI. Helps avoid clobbering the CI configuration. - [./steps/fmt.sh](./steps/fmt.sh) - - Runs `yarn fmt` after ensuring VS Code is patched. + - Runs `yarn fmt`. - [./steps/lint.sh](./steps/lint.sh) - - Runs `yarn lint` after ensuring VS Code is patched. -- [./steps/test.sh](./steps/test.sh) - - Runs `yarn test` after ensuring VS Code is patched. + - Runs `yarn lint`. +- [./steps/test-unit.sh](./steps/test-unit.sh) + - Runs `yarn test:unit`. +- [./steps/test-e2e.sh](./steps/test-e2e.sh) + - Runs `yarn test:e2e`. - [./steps/release.sh](./steps/release.sh) - Runs the release process. - Generates the npm package at `./release`. diff --git a/ci/dev/ci.sh b/ci/dev/ci.sh index e9268286..92265a97 100755 --- a/ci/dev/ci.sh +++ b/ci/dev/ci.sh @@ -6,7 +6,7 @@ main() { yarn fmt yarn lint - yarn test + yarn test:unit } main "$@" diff --git a/ci/dev/test.sh b/ci/dev/test-e2e.sh similarity index 85% rename from ci/dev/test.sh rename to ci/dev/test-e2e.sh index 82f6ad36..d81d25cb 100755 --- a/ci/dev/test.sh +++ b/ci/dev/test-e2e.sh @@ -3,12 +3,9 @@ set -euo pipefail main() { cd "$(dirname "$0")/../.." - cd test/test-plugin - make -s out/index.js # We must keep jest in a sub-directory. See ../../test/package.json for more # information. We must also run it from the root otherwise coverage will not # include our source files. - cd "$OLDPWD" if [[ -z ${PASSWORD-} ]] || [[ -z ${CODE_SERVER_ADDRESS-} ]]; then echo "The end-to-end testing suites rely on your local environment" echo -e "\n" @@ -21,7 +18,7 @@ main() { echo -e "\n" exit 1 fi - CS_DISABLE_PLUGINS=true ./test/node_modules/.bin/jest "$@" + CS_DISABLE_PLUGINS=true ./test/node_modules/.bin/jest "$@" --config ./test/jest.e2e.config.ts } main "$@" diff --git a/ci/dev/test-unit.sh b/ci/dev/test-unit.sh new file mode 100755 index 00000000..f2e76ee5 --- /dev/null +++ b/ci/dev/test-unit.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -euo pipefail + +main() { + cd "$(dirname "$0")/../.." + cd test/unit/test-plugin + make -s out/index.js + # We must keep jest in a sub-directory. See ../../test/package.json for more + # information. We must also run it from the root otherwise coverage will not + # include our source files. + cd "$OLDPWD" + CS_DISABLE_PLUGINS=true ./test/node_modules/.bin/jest "$@" +} + +main "$@" diff --git a/ci/steps/test-e2e.sh b/ci/steps/test-e2e.sh new file mode 100755 index 00000000..c43fbd07 --- /dev/null +++ b/ci/steps/test-e2e.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -euo pipefail + +main() { + cd "$(dirname "$0")/../.." + + "./release-packages/code-server*-linux-amd64/bin/code-server" --home "$CODE_SERVER_ADDRESS"/healthz & + yarn --frozen-lockfile + yarn test:e2e +} + +main "$@" diff --git a/ci/steps/test.sh b/ci/steps/test-unit.sh similarity index 87% rename from ci/steps/test.sh rename to ci/steps/test-unit.sh index 72aa3ca2..77fd547c 100755 --- a/ci/steps/test.sh +++ b/ci/steps/test-unit.sh @@ -6,7 +6,7 @@ main() { yarn --frozen-lockfile - yarn test + yarn test:unit } main "$@" diff --git a/package.json b/package.json index 10aadeb2..50541dda 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,9 @@ "release:standalone": "./ci/build/build-standalone-release.sh", "release:github-draft": "./ci/build/release-github-draft.sh", "release:github-assets": "./ci/build/release-github-assets.sh", + "test:e2e": "./ci/dev/test-e2e.sh", "test:standalone-release": "./ci/build/test-standalone-release.sh", + "test:unit": "./ci/dev/test-unit.sh", "package": "./ci/build/build-packages.sh", "postinstall": "./ci/dev/postinstall.sh", "update:vscode": "./ci/dev/update-vscode.sh", @@ -124,7 +126,8 @@ "testPathIgnorePatterns": [ "node_modules", "lib", - "out" + "out", + "test/e2e" ], "collectCoverage": true, "collectCoverageFrom": [ @@ -144,8 +147,6 @@ "lines": 40 } }, - "testTimeout": 30000, - "globalSetup": "/test/globalSetup.ts", "modulePathIgnorePatterns": [ "/lib/vscode", "/release-packages", @@ -156,7 +157,7 @@ "/release-images" ], "moduleNameMapper": { - "^.+\\.(css|less)$": "/test/cssStub.ts" + "^.+\\.(css|less)$": "/test/utils/cssStub.ts" } } } diff --git a/test/e2e.test.ts b/test/e2e/e2e.test.ts similarity index 89% rename from test/e2e.test.ts rename to test/e2e/e2e.test.ts index 21df386b..4e60c6eb 100644 --- a/test/e2e.test.ts +++ b/test/e2e/e2e.test.ts @@ -1,5 +1,5 @@ import { chromium, Page, Browser } from "playwright" -import { CODE_SERVER_ADDRESS } from "./constants" +import { CODE_SERVER_ADDRESS } from "../utils/constants" let browser: Browser let page: Page diff --git a/test/goHome.test.ts b/test/e2e/goHome.test.ts similarity index 92% rename from test/goHome.test.ts rename to test/e2e/goHome.test.ts index 40d6a838..b57b2a19 100644 --- a/test/goHome.test.ts +++ b/test/e2e/goHome.test.ts @@ -1,7 +1,7 @@ import { chromium, Page, Browser, BrowserContext, Cookie } from "playwright" -import { hash } from "../src/node/util" -import { CODE_SERVER_ADDRESS, PASSWORD, STORAGE } from "./constants" -import { createCookieIfDoesntExist } from "./helpers" +import { hash } from "../../src/node/util" +import { CODE_SERVER_ADDRESS, PASSWORD, STORAGE, E2E_VIDEO_DIR } from "../utils/constants" +import { createCookieIfDoesntExist } from "../utils/helpers" describe("go home", () => { let browser: Browser @@ -45,7 +45,7 @@ describe("go home", () => { context = await browser.newContext({ storageState: { cookies: maybeUpdatedCookies }, - recordVideo: { dir: "./test/videos/" }, + recordVideo: { dir: E2E_VIDEO_DIR }, }) }) diff --git a/test/login.test.ts b/test/e2e/login.test.ts similarity index 93% rename from test/login.test.ts rename to test/e2e/login.test.ts index b269acbd..ca098904 100644 --- a/test/login.test.ts +++ b/test/e2e/login.test.ts @@ -1,5 +1,5 @@ import { chromium, Page, Browser, BrowserContext } from "playwright" -import { CODE_SERVER_ADDRESS, PASSWORD } from "./constants" +import { CODE_SERVER_ADDRESS, PASSWORD } from "../utils/constants" describe("login", () => { let browser: Browser diff --git a/test/jest.e2e.config.ts b/test/jest.e2e.config.ts new file mode 100644 index 00000000..01f9b607 --- /dev/null +++ b/test/jest.e2e.config.ts @@ -0,0 +1,22 @@ +// jest.config.ts +import type { Config } from "@jest/types" + +const config: Config.InitialOptions = { + transform: { + "^.+\\.ts$": "/node_modules/ts-jest", + }, + globalSetup: "/utils/globalSetup.ts", + testEnvironment: "node", + testPathIgnorePatterns: ["node_modules", "lib", "out", "test/unit"], + testTimeout: 30000, + modulePathIgnorePatterns: [ + "/../lib/vscode", + "/../release-packages", + "/../release", + "/../release-standalone", + "/../release-npm-package", + "/../release-gcp", + "/../release-images", + ], +} +export default config diff --git a/test/cli.test.ts b/test/unit/cli.test.ts similarity index 99% rename from test/cli.test.ts rename to test/unit/cli.test.ts index 6a0cfd7b..94c72205 100644 --- a/test/cli.test.ts +++ b/test/unit/cli.test.ts @@ -3,8 +3,8 @@ import * as fs from "fs-extra" import * as net from "net" import * as os from "os" import * as path from "path" -import { Args, parse, setDefaults, shouldOpenInExistingInstance } from "../src/node/cli" -import { paths, tmpdir } from "../src/node/util" +import { Args, parse, setDefaults, shouldOpenInExistingInstance } from "../../src/node/cli" +import { paths, tmpdir } from "../../src/node/util" type Mutable = { -readonly [P in keyof T]: T[P] diff --git a/test/constants.test.ts b/test/unit/constants.test.ts similarity index 90% rename from test/constants.test.ts rename to test/unit/constants.test.ts index 0cb33f2f..e4b14a6c 100644 --- a/test/constants.test.ts +++ b/test/unit/constants.test.ts @@ -1,8 +1,8 @@ -import { commit, getPackageJson, version } from "../src/node/constants" -import { loggerModule } from "./helpers" +import { commit, getPackageJson, version } from "../../src/node/constants" +import { loggerModule } from "../utils/helpers" // jest.mock is hoisted above the imports so we must use `require` here. -jest.mock("@coder/logger", () => require("./helpers").loggerModule) +jest.mock("@coder/logger", () => require("../utils/helpers").loggerModule) describe("constants", () => { describe("getPackageJson", () => { diff --git a/test/emitter.test.ts b/test/unit/emitter.test.ts similarity index 95% rename from test/emitter.test.ts rename to test/unit/emitter.test.ts index 3ea72ae2..ebc6491b 100644 --- a/test/emitter.test.ts +++ b/test/unit/emitter.test.ts @@ -1,8 +1,8 @@ // Note: we need to import logger from the root // because this is the logger used in logError in ../src/common/util -import { logger } from "../node_modules/@coder/logger" +import { logger } from "../../node_modules/@coder/logger" -import { Emitter } from "../src/common/emitter" +import { Emitter } from "../../src/common/emitter" describe("emitter", () => { let spy: jest.SpyInstance diff --git a/test/health.test.ts b/test/unit/health.test.ts similarity index 91% rename from test/health.test.ts rename to test/unit/health.test.ts index 4eae9c60..a8bdfb19 100644 --- a/test/health.test.ts +++ b/test/unit/health.test.ts @@ -1,5 +1,5 @@ -import * as httpserver from "./httpserver" -import * as integration from "./integration" +import * as httpserver from "../utils/httpserver" +import * as integration from "../utils/integration" describe("health", () => { let codeServer: httpserver.HttpServer | undefined diff --git a/test/http.test.ts b/test/unit/http.test.ts similarity index 94% rename from test/http.test.ts rename to test/unit/http.test.ts index 234fca0d..5275adc8 100644 --- a/test/http.test.ts +++ b/test/unit/http.test.ts @@ -1,4 +1,4 @@ -import { HttpCode, HttpError } from "../src/common/http" +import { HttpCode, HttpError } from "../../src/common/http" describe("http", () => { describe("HttpCode", () => { diff --git a/test/plugin.test.ts b/test/unit/plugin.test.ts similarity index 92% rename from test/plugin.test.ts rename to test/unit/plugin.test.ts index 24326ded..7df360df 100644 --- a/test/plugin.test.ts +++ b/test/unit/plugin.test.ts @@ -2,11 +2,11 @@ import { logger } from "@coder/logger" import * as express from "express" import * as fs from "fs" import * as path from "path" -import { HttpCode } from "../src/common/http" -import { AuthType } from "../src/node/cli" -import { codeServer, PluginAPI } from "../src/node/plugin" -import * as apps from "../src/node/routes/apps" -import * as httpserver from "./httpserver" +import { HttpCode } from "../../src/common/http" +import { AuthType } from "../../src/node/cli" +import { codeServer, PluginAPI } from "../../src/node/plugin" +import * as apps from "../../src/node/routes/apps" +import * as httpserver from "../utils/httpserver" const fsp = fs.promises // Jest overrides `require` so our usual override doesn't work. diff --git a/test/proxy.test.ts b/test/unit/proxy.test.ts similarity index 96% rename from test/proxy.test.ts rename to test/unit/proxy.test.ts index 84a2c35b..c5969ebf 100644 --- a/test/proxy.test.ts +++ b/test/unit/proxy.test.ts @@ -1,7 +1,7 @@ import bodyParser from "body-parser" import * as express from "express" -import * as httpserver from "./httpserver" -import * as integration from "./integration" +import * as httpserver from "../utils/httpserver" +import * as integration from "../utils/integration" describe("proxy", () => { const nhooyrDevServer = new httpserver.HttpServer() diff --git a/test/register.test.ts b/test/unit/register.test.ts similarity index 93% rename from test/register.test.ts rename to test/unit/register.test.ts index a80c2034..d19f6300 100644 --- a/test/register.test.ts +++ b/test/unit/register.test.ts @@ -1,5 +1,5 @@ import { JSDOM } from "jsdom" -import { loggerModule } from "./helpers" +import { loggerModule } from "../utils/helpers" describe("register", () => { describe("when navigator and serviceWorker are defined", () => { @@ -40,7 +40,7 @@ describe("register", () => { it("should register a ServiceWorker", () => { // Load service worker like you would in the browser - require("../src/browser/register") + require("../../src/browser/register") expect(mockRegisterFn).toHaveBeenCalled() expect(mockRegisterFn).toHaveBeenCalledTimes(1) }) @@ -54,7 +54,7 @@ describe("register", () => { }) // Load service worker like you would in the browser - require("../src/browser/register") + require("../../src/browser/register") expect(mockRegisterFn).toHaveBeenCalled() expect(loggerModule.logger.error).toHaveBeenCalled() @@ -78,7 +78,7 @@ describe("register", () => { it("should log an error to the console", () => { // Load service worker like you would in the browser - require("../src/browser/register") + require("../../src/browser/register") expect(spy).toHaveBeenCalled() expect(spy).toHaveBeenCalledTimes(1) expect(spy).toHaveBeenCalledWith("[Service Worker] navigator is undefined") diff --git a/test/serviceWorker.test.ts b/test/unit/serviceWorker.test.ts similarity index 91% rename from test/serviceWorker.test.ts rename to test/unit/serviceWorker.test.ts index 7933d1f4..c8b0a625 100644 --- a/test/serviceWorker.test.ts +++ b/test/unit/serviceWorker.test.ts @@ -58,7 +58,7 @@ describe("serviceWorker", () => { }) it("should add 3 listeners: install, activate and fetch", () => { - require("../src/browser/serviceWorker.ts") + require("../../src/browser/serviceWorker.ts") const listenerEventNames = listeners.map((listener) => listener.event) expect(listeners).toHaveLength(3) @@ -68,20 +68,20 @@ describe("serviceWorker", () => { }) it("should call the proper callbacks for 'install'", async () => { - require("../src/browser/serviceWorker.ts") + require("../../src/browser/serviceWorker.ts") emit("install") expect(spy).toHaveBeenCalledWith("[Service Worker] installed") expect(spy).toHaveBeenCalledTimes(1) }) it("should do nothing when 'fetch' is called", async () => { - require("../src/browser/serviceWorker.ts") + require("../../src/browser/serviceWorker.ts") emit("fetch") expect(spy).not.toHaveBeenCalled() }) it("should call the proper callbacks for 'activate'", async () => { - require("../src/browser/serviceWorker.ts") + require("../../src/browser/serviceWorker.ts") emit("activate") // Activate serviceWorker diff --git a/test/socket.test.ts b/test/unit/socket.test.ts similarity index 96% rename from test/socket.test.ts rename to test/unit/socket.test.ts index e614e94d..da0b404a 100644 --- a/test/socket.test.ts +++ b/test/unit/socket.test.ts @@ -3,9 +3,9 @@ import * as fs from "fs-extra" import * as net from "net" import * as path from "path" import * as tls from "tls" -import { Emitter } from "../src/common/emitter" -import { SocketProxyProvider } from "../src/node/socket" -import { generateCertificate, tmpdir } from "../src/node/util" +import { Emitter } from "../../src/common/emitter" +import { SocketProxyProvider } from "../../src/node/socket" +import { generateCertificate, tmpdir } from "../../src/node/util" describe("SocketProxyProvider", () => { const provider = new SocketProxyProvider() diff --git a/test/test-plugin/.eslintrc.yaml b/test/unit/test-plugin/.eslintrc.yaml similarity index 100% rename from test/test-plugin/.eslintrc.yaml rename to test/unit/test-plugin/.eslintrc.yaml diff --git a/test/test-plugin/.gitignore b/test/unit/test-plugin/.gitignore similarity index 100% rename from test/test-plugin/.gitignore rename to test/unit/test-plugin/.gitignore diff --git a/test/test-plugin/Makefile b/test/unit/test-plugin/Makefile similarity index 100% rename from test/test-plugin/Makefile rename to test/unit/test-plugin/Makefile diff --git a/test/test-plugin/package.json b/test/unit/test-plugin/package.json similarity index 100% rename from test/test-plugin/package.json rename to test/unit/test-plugin/package.json diff --git a/test/test-plugin/public/icon.svg b/test/unit/test-plugin/public/icon.svg similarity index 100% rename from test/test-plugin/public/icon.svg rename to test/unit/test-plugin/public/icon.svg diff --git a/test/test-plugin/public/index.html b/test/unit/test-plugin/public/index.html similarity index 100% rename from test/test-plugin/public/index.html rename to test/unit/test-plugin/public/index.html diff --git a/test/test-plugin/src/index.ts b/test/unit/test-plugin/src/index.ts similarity index 100% rename from test/test-plugin/src/index.ts rename to test/unit/test-plugin/src/index.ts diff --git a/test/test-plugin/tsconfig.json b/test/unit/test-plugin/tsconfig.json similarity index 99% rename from test/test-plugin/tsconfig.json rename to test/unit/test-plugin/tsconfig.json index 5afea81b..bb30a1ad 100644 --- a/test/test-plugin/tsconfig.json +++ b/test/unit/test-plugin/tsconfig.json @@ -44,7 +44,7 @@ // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ "baseUrl": "./" /* Base directory to resolve non-absolute module names. */, "paths": { - "code-server": ["../../typings/pluginapi"] + "code-server": ["../../../typings/pluginapi"] } /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */, // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "typeRoots": [], /* List of folders to include type definitions from. */ diff --git a/test/test-plugin/yarn.lock b/test/unit/test-plugin/yarn.lock similarity index 100% rename from test/test-plugin/yarn.lock rename to test/unit/test-plugin/yarn.lock diff --git a/test/update.test.ts b/test/unit/update.test.ts similarity index 95% rename from test/update.test.ts rename to test/unit/update.test.ts index d275be4a..0f5d55a6 100644 --- a/test/update.test.ts +++ b/test/unit/update.test.ts @@ -1,9 +1,9 @@ import * as fs from "fs-extra" import * as http from "http" import * as path from "path" -import { SettingsProvider, UpdateSettings } from "../src/node/settings" -import { LatestResponse, UpdateProvider } from "../src/node/update" -import { tmpdir } from "../src/node/util" +import { SettingsProvider, UpdateSettings } from "../../src/node/settings" +import { LatestResponse, UpdateProvider } from "../../src/node/update" +import { tmpdir } from "../../src/node/util" describe.skip("update", () => { let version = "1.0.0" diff --git a/test/util.test.ts b/test/unit/util.test.ts similarity index 96% rename from test/util.test.ts rename to test/unit/util.test.ts index 2681d877..31eace76 100644 --- a/test/util.test.ts +++ b/test/unit/util.test.ts @@ -10,11 +10,11 @@ import { split, trimSlashes, normalize, -} from "../src/common/util" -import { Cookie as CookieEnum } from "../src/node/routes/login" -import { hash } from "../src/node/util" -import { PASSWORD } from "./constants" -import { checkForCookie, createCookieIfDoesntExist, loggerModule, Cookie } from "./helpers" +} from "../../src/common/util" +import { Cookie as CookieEnum } from "../../src/node/routes/login" +import { hash } from "../../src/node/util" +import { PASSWORD } from "../utils/constants" +import { checkForCookie, createCookieIfDoesntExist, loggerModule, Cookie } from "../utils/helpers" const dom = new JSDOM() global.document = dom.window.document @@ -22,7 +22,7 @@ global.document = dom.window.document type LocationLike = Pick // jest.mock is hoisted above the imports so we must use `require` here. -jest.mock("@coder/logger", () => require("./helpers").loggerModule) +jest.mock("@coder/logger", () => require("../utils/helpers").loggerModule) describe("util", () => { describe("normalize", () => { diff --git a/test/constants.ts b/test/utils/constants.ts similarity index 80% rename from test/constants.ts rename to test/utils/constants.ts index ac2250e1..9a750892 100644 --- a/test/constants.ts +++ b/test/utils/constants.ts @@ -1,3 +1,4 @@ export const CODE_SERVER_ADDRESS = process.env.CODE_SERVER_ADDRESS || "http://localhost:8080" export const PASSWORD = process.env.PASSWORD || "e45432jklfdsab" export const STORAGE = process.env.STORAGE || "" +export const E2E_VIDEO_DIR = "./test/e2e/videos" diff --git a/test/cssStub.ts b/test/utils/cssStub.ts similarity index 100% rename from test/cssStub.ts rename to test/utils/cssStub.ts diff --git a/test/globalSetup.ts b/test/utils/globalSetup.ts similarity index 87% rename from test/globalSetup.ts rename to test/utils/globalSetup.ts index 5ef45faa..36b242d7 100644 --- a/test/globalSetup.ts +++ b/test/utils/globalSetup.ts @@ -6,7 +6,7 @@ import { CODE_SERVER_ADDRESS, PASSWORD } from "./constants" import * as wtfnode from "./wtfnode" module.exports = async () => { - console.log("\n🚨 Running Global Setup for Jest Tests") + console.log("\n🚨 Running Global Setup for Jest End-to-End Tests") console.log(" Please hang tight...") const browser = await chromium.launch() const context = await browser.newContext() @@ -30,5 +30,5 @@ module.exports = async () => { await page.close() await browser.close() await context.close() - console.log("✅ Global Setup for Jest Tests is now complete.") + console.log("✅ Global Setup for Jest End-to-End Tests is now complete.") } diff --git a/test/helpers.ts b/test/utils/helpers.ts similarity index 100% rename from test/helpers.ts rename to test/utils/helpers.ts diff --git a/test/httpserver.ts b/test/utils/httpserver.ts similarity index 95% rename from test/httpserver.ts rename to test/utils/httpserver.ts index 399ccda1..a66bbbff 100644 --- a/test/httpserver.ts +++ b/test/utils/httpserver.ts @@ -3,9 +3,9 @@ import * as http from "http" import * as net from "net" import * as nodeFetch from "node-fetch" import Websocket from "ws" -import * as util from "../src/common/util" -import { ensureAddress } from "../src/node/app" -import { handleUpgrade } from "../src/node/wsRouter" +import * as util from "../../src/common/util" +import { ensureAddress } from "../../src/node/app" +import { handleUpgrade } from "../../src/node/wsRouter" // Perhaps an abstraction similar to this should be used in app.ts as well. export class HttpServer { diff --git a/test/integration.ts b/test/utils/integration.ts similarity index 85% rename from test/integration.ts rename to test/utils/integration.ts index f829fe5d..c5101d0f 100644 --- a/test/integration.ts +++ b/test/utils/integration.ts @@ -1,7 +1,7 @@ import * as express from "express" -import { createApp } from "../src/node/app" -import { parse, setDefaults, parseConfigFile, DefaultedArgs } from "../src/node/cli" -import { register } from "../src/node/routes" +import { createApp } from "../../src/node/app" +import { parse, setDefaults, parseConfigFile, DefaultedArgs } from "../../src/node/cli" +import { register } from "../../src/node/routes" import * as httpserver from "./httpserver" export async function setup( diff --git a/test/wtfnode.ts b/test/utils/wtfnode.ts similarity index 100% rename from test/wtfnode.ts rename to test/utils/wtfnode.ts