File tree 5 files changed +33
-29
lines changed
5 files changed +33
-29
lines changed Original file line number Diff line number Diff line change 1
- import { test , expect } from "@playwright/test"
1
+ import { expect , test } from "@playwright/test"
2
2
import * as cp from "child_process"
3
3
import * as fs from "fs"
4
- // import { tmpdir } from "os"
5
4
import * as path from "path"
6
5
import util from "util"
7
- import { STORAGE , tmpdir } from "../utils/constants"
6
+ import { STORAGE } from "../utils/constants"
7
+ import { tmpdir } from "../utils/helpers"
8
8
import { CodeServer } from "./models/CodeServer"
9
9
10
10
test . describe ( "Integrated Terminal" , ( ) => {
Original file line number Diff line number Diff line change 1
- import * as fs from "fs"
2
1
import { commit , getPackageJson , version } from "../../src/node/constants"
3
- import { tmpdir } from "../../test/utils/constants"
4
2
import { loggerModule } from "../utils/helpers"
5
3
6
4
// jest.mock is hoisted above the imports so we must use `require` here.
@@ -53,16 +51,3 @@ describe("constants", () => {
53
51
} )
54
52
} )
55
53
} )
56
-
57
- describe ( "test constants" , ( ) => {
58
- describe ( "tmpdir" , ( ) => {
59
- it ( "should return a temp directory" , async ( ) => {
60
- const testName = "temp-dir"
61
- const pathToTempDir = await tmpdir ( testName )
62
-
63
- expect ( pathToTempDir ) . toContain ( testName )
64
-
65
- await fs . promises . rmdir ( pathToTempDir )
66
- } )
67
- } )
68
- } )
Original file line number Diff line number Diff line change
1
+ import { promises as fs } from "fs"
2
+ import { tmpdir } from "../../test/utils/helpers"
3
+
4
+ /**
5
+ * This file is for testing test helpers (not core code).
6
+ */
7
+ describe ( "test helpers" , ( ) => {
8
+ it ( "should return a temp directory" , async ( ) => {
9
+ const testName = "temp-dir"
10
+ const pathToTempDir = await tmpdir ( testName )
11
+ expect ( pathToTempDir ) . toContain ( testName )
12
+ expect ( fs . access ( pathToTempDir ) ) . resolves . toStrictEqual ( undefined )
13
+ } )
14
+ } )
Original file line number Diff line number Diff line change 1
- import * as fs from "fs"
2
- import * as os from "os"
3
- import * as path from "path"
4
-
5
1
export const CODE_SERVER_ADDRESS = process . env . CODE_SERVER_ADDRESS || "http://localhost:8080"
6
2
export const PASSWORD = process . env . PASSWORD || "e45432jklfdsab"
7
3
export const STORAGE = process . env . STORAGE || ""
8
-
9
- export async function tmpdir ( testName : string ) : Promise < string > {
10
- const dir = path . join ( os . tmpdir ( ) , "code-server" )
11
- await fs . promises . mkdir ( dir , { recursive : true } )
12
-
13
- return await fs . promises . mkdtemp ( path . join ( dir , `test-${ testName } -` ) , { encoding : "utf8" } )
14
- }
Original file line number Diff line number Diff line change
1
+ import * as fs from "fs"
2
+ import * as os from "os"
3
+ import * as path from "path"
4
+
1
5
export const loggerModule = {
2
6
field : jest . fn ( ) ,
3
7
level : 2 ,
@@ -9,3 +13,15 @@ export const loggerModule = {
9
13
warn : jest . fn ( ) ,
10
14
} ,
11
15
}
16
+
17
+ /**
18
+ * Create a uniquely named temporary directory.
19
+ *
20
+ * These directories are placed under a single temporary code-server directory.
21
+ */
22
+ export async function tmpdir ( testName : string ) : Promise < string > {
23
+ const dir = path . join ( os . tmpdir ( ) , "code-server" )
24
+ await fs . promises . mkdir ( dir , { recursive : true } )
25
+
26
+ return await fs . promises . mkdtemp ( path . join ( dir , `test-${ testName } -` ) , { encoding : "utf8" } )
27
+ }
You can’t perform that action at this time.
0 commit comments