File tree 3 files changed +29
-3
lines changed 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 1
1
import { test , expect } from "@playwright/test"
2
2
import * as fs from "fs"
3
- import { tmpdir } from "os"
3
+ // import { tmpdir } from "os"
4
4
import * as path from "path"
5
5
import util from "util"
6
6
import * as cp from "child_process"
7
- import { STORAGE } from "../utils/constants"
7
+ import { STORAGE , tmpdir } from "../utils/constants"
8
8
import { CodeServer } from "./models/CodeServer"
9
9
10
10
test . describe ( "Integrated Terminal" , ( ) => {
@@ -33,7 +33,7 @@ test.describe("Integrated Terminal", () => {
33
33
// We're not using tmpdir from src/node/constants
34
34
// because Playwright doesn't fully support ES modules from
35
35
// the erorrs I'm seeing
36
- tmpFolderPath = fs . mkdtempSync ( path . join ( tmpdir ( ) , "code-server-test" ) )
36
+ tmpFolderPath = await tmpdir ( "integrated-terminal" )
37
37
tmpFile = path . join ( tmpFolderPath , testFileName )
38
38
} )
39
39
Original file line number Diff line number Diff line change
1
+ import * as fs from "fs"
1
2
import { commit , getPackageJson , version } from "../../src/node/constants"
3
+ import { tmpdir } from "../../test/utils/constants"
2
4
import { loggerModule } from "../utils/helpers"
3
5
4
6
// jest.mock is hoisted above the imports so we must use `require` here.
@@ -51,3 +53,16 @@ describe("constants", () => {
51
53
} )
52
54
} )
53
55
} )
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 . rmdir ( pathToTempDir , ( ) => { } )
66
+ } )
67
+ } )
68
+ } )
Original file line number Diff line number Diff line change
1
+ import * as os from "os"
2
+ import * as path from "path"
3
+ import * as fs from "fs"
4
+
1
5
export const CODE_SERVER_ADDRESS = process . env . CODE_SERVER_ADDRESS || "http://localhost:8080"
2
6
export const PASSWORD = process . env . PASSWORD || "e45432jklfdsab"
3
7
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 . mkdir ( dir , { recursive : true } , ( ) => { } )
12
+
13
+ return await fs . promises . mkdtemp ( path . join ( dir , `test-${ testName } -` ) , { encoding : "utf8" } )
14
+ }
You can’t perform that action at this time.
0 commit comments