@@ -12,7 +12,6 @@ describe("login", () => {
12
12
// Create a new context with the saved storage state
13
13
const storageState = JSON . parse ( process . env . STORAGE || "" )
14
14
15
- //
16
15
const cookieToStore = {
17
16
sameSite : "Lax" as const ,
18
17
name : "key" ,
@@ -61,16 +60,20 @@ describe("login", () => {
61
60
62
61
// NOTE: this test will fail if you do not run code-server with --home $CODE_SERVER_ADDRESS/healthz
63
62
it ( "should see a 'Go Home' button in the Application Menu that goes to /healthz" , async ( done ) => {
63
+ let requestedGoHomeUrl = false
64
64
// Ideally, this test should pass and finish before the timeout set in the Jest config
65
65
// However, if it doesn't, we don't want a memory leak so we set this backup timeout
66
66
// Otherwise Jest may throw this error
67
67
// "Jest did not exit one second after the test run has completed.
68
68
// This usually means that there are asynchronous operations that weren't stopped in your tests.
69
69
// Consider running Jest with `--detectOpenHandles` to troubleshoot this issue."
70
- const backupTimeout = setTimeout ( ( ) => done ( ) , 20000 )
70
+ const backupTimeout = setTimeout ( ( ) => {
71
+ // If it's not true by this point then the test should fail
72
+ expect ( requestedGoHomeUrl ) . toBeTruthy ( )
73
+ done ( )
74
+ } , 20000 )
71
75
72
76
const GO_HOME_URL = `${ process . env . CODE_SERVER_ADDRESS } /healthz`
73
- let requestedGoHomeUrl = false
74
77
page . on ( "request" , ( request ) => {
75
78
// This ensures that we did make a request to the GO_HOME_URL
76
79
// Most reliable way to test button
0 commit comments