File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed
Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 11import { test , expect } from "@playwright/test"
22import * as fs from "fs"
3- import { tmpdir } from "os"
3+ // import { tmpdir } from "os"
44import * as path from "path"
55import util from "util"
66import * as cp from "child_process"
7- import { STORAGE } from "../utils/constants"
7+ import { STORAGE , tmpdir } from "../utils/constants"
88import { CodeServer } from "./models/CodeServer"
99
1010test . describe ( "Integrated Terminal" , ( ) => {
@@ -33,7 +33,7 @@ test.describe("Integrated Terminal", () => {
3333 // We're not using tmpdir from src/node/constants
3434 // because Playwright doesn't fully support ES modules from
3535 // the erorrs I'm seeing
36- tmpFolderPath = fs . mkdtempSync ( path . join ( tmpdir ( ) , "code-server-test" ) )
36+ tmpFolderPath = await tmpdir ( "integrated-terminal" )
3737 tmpFile = path . join ( tmpFolderPath , testFileName )
3838 } )
3939
Original file line number Diff line number Diff line change 1+ import * as fs from "fs"
12import { commit , getPackageJson , version } from "../../src/node/constants"
3+ import { tmpdir } from "../../test/utils/constants"
24import { loggerModule } from "../utils/helpers"
35
46// jest.mock is hoisted above the imports so we must use `require` here.
@@ -51,3 +53,16 @@ describe("constants", () => {
5153 } )
5254 } )
5355} )
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+
15export const CODE_SERVER_ADDRESS = process . env . CODE_SERVER_ADDRESS || "http://localhost:8080"
26export const PASSWORD = process . env . PASSWORD || "e45432jklfdsab"
37export 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