feat(testing): add test for app > listen (#4971)
* feat(testing): add test for app > listen * Update test/unit/node/app.test.ts * refactor: modernize listen fn in app * wip * fix: update error message * fixup: remove console.log * fixup: use clearAllMocks once in beforeAll * fix: move chmod after socket listen * fixup: formatting * Update src/node/app.ts Co-authored-by: Jonathan Yu <jonathan@coder.com> * Update src/node/app.ts Co-authored-by: Asher <ash@coder.com> Co-authored-by: Jonathan Yu <jonathan@coder.com> Co-authored-by: Asher <ash@coder.com>
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import { logger } from "@coder/logger"
|
||||
import { mockLogger } from "../../utils/helpers"
|
||||
import * as semver from "semver"
|
||||
import path from "path"
|
||||
|
||||
describe("constants", () => {
|
||||
let constants: typeof import("../../../src/node/constants")
|
||||
@ -20,14 +21,18 @@ describe("constants", () => {
|
||||
}
|
||||
|
||||
beforeAll(() => {
|
||||
jest.clearAllMocks()
|
||||
mockLogger()
|
||||
jest.mock("../../../package.json", () => mockPackageJson, { virtual: true })
|
||||
jest.mock("../../../vendor/modules/code-oss-dev/package.json", () => mockCodePackageJson, { virtual: true })
|
||||
jest.mock(path.resolve(__dirname, "../../../package.json"), () => mockPackageJson, { virtual: true })
|
||||
jest.mock(
|
||||
path.resolve(__dirname, "../../../vendor/modules/code-oss-dev/package.json"),
|
||||
() => mockCodePackageJson,
|
||||
{ virtual: true },
|
||||
)
|
||||
constants = require("../../../src/node/constants")
|
||||
})
|
||||
|
||||
afterAll(() => {
|
||||
jest.clearAllMocks()
|
||||
jest.resetModules()
|
||||
})
|
||||
|
||||
@ -106,13 +111,17 @@ describe("constants", () => {
|
||||
}
|
||||
|
||||
beforeAll(() => {
|
||||
jest.mock("../../../package.json", () => mockPackageJson, { virtual: true })
|
||||
jest.mock("../../../vendor/modules/code-oss-dev/package.json", () => mockCodePackageJson, { virtual: true })
|
||||
jest.clearAllMocks()
|
||||
jest.mock(path.resolve(__dirname, "../../../package.json"), () => mockPackageJson, { virtual: true })
|
||||
jest.mock(
|
||||
path.resolve(__dirname, "../../../vendor/modules/code-oss-dev/package.json"),
|
||||
() => mockCodePackageJson,
|
||||
{ virtual: true },
|
||||
)
|
||||
constants = require("../../../src/node/constants")
|
||||
})
|
||||
|
||||
afterAll(() => {
|
||||
jest.clearAllMocks()
|
||||
jest.resetModules()
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user