Skip to content

Commit b215880

Browse files
committed
optimize error reporting ux
1 parent 11a9ece commit b215880

2 files changed

Lines changed: 26 additions & 14 deletions

File tree

packages/e2e/setup/app.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ export const appScaffoldFixture = authFixture.extend<{appScaffold: AppScaffold}>
7878
timeout: 5 * 60 * 1000,
7979
})
8080

81+
if (result.exitCode !== 0) {
82+
return result
83+
}
84+
8185
const allOutput = `${result.stdout}\n${result.stderr}`
8286
const match = allOutput.match(/([\w-]+) is ready for you to build!/)
8387

packages/e2e/tests/app-basic.spec.ts

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,40 @@ test.describe('App basic flow (no extensions)', () => {
2121
flavor: 'javascript',
2222
packageManager: 'npm',
2323
})
24-
expect(initResult.exitCode, `app init failed:\n${initResult.stdout}\n${initResult.stderr}`).toBe(0)
24+
expect(initResult.exitCode, '‼️ Step 1 - app init failed').toBe(0)
2525

2626
// Step 2: Start dev server via PTY
2727
// Unset CI so keyboard shortcuts are enabled in the Dev UI
2828
const dev = await cli.spawn(['app', 'dev', '--path', appScaffold.appDir], {env: {CI: ''}})
2929
try {
30-
await dev.waitForOutput('Ready, watching for changes in your app', 3 * 60 * 1000)
30+
await dev.waitForOutput('Ready, watching for changes in your app', 3 * 60 * 1000).catch((err: Error) => {
31+
throw new Error(`‼️ Step 2 - app dev failed\n${err.message}`)
32+
})
3133

3234
// Step 3: Run a GraphQL query while the dev server is running
3335
const executeResult = await cli.exec(
3436
['app', 'execute', '--query', 'query { shop { name } }', '--path', appScaffold.appDir],
3537
{timeout: 60 * 1000},
3638
)
3739
const executeOutput = executeResult.stdout + executeResult.stderr
38-
expect(executeResult.exitCode, `app execute failed:\n${executeOutput}`).toBe(0)
39-
expect(executeOutput).toContain('shop')
40+
expect(executeResult.exitCode, '‼️ Step 3 - app execute failed').toBe(0)
41+
expect(executeOutput, '‼️ Step 3 - app execute: response missing "shop" field').toContain('shop')
4042

4143
// Step 4: Press q to quit the dev server
4244
dev.sendKey('q')
43-
const devExitCode = await dev.waitForExit(30_000)
44-
expect(devExitCode).toBe(0)
45+
const devExitCode = await dev.waitForExit(30_000).catch((err: Error) => {
46+
throw new Error(`‼️ Step 4 - app dev did not exit after pressing q\n${err.message}`)
47+
})
48+
expect(devExitCode, '‼️ Step 4 - app dev quit failed').toBe(0)
4549
} finally {
4650
// Step 5: Always clean up the dev preview, even if the test fails
4751
dev.kill()
4852
const cleanResult = await cli.exec(['app', 'dev', 'clean', '--path', appScaffold.appDir])
4953
const cleanOutput = cleanResult.stdout + cleanResult.stderr
50-
expect(cleanResult.exitCode, `dev clean failed:\n${cleanOutput}`).toBe(0)
51-
expect(cleanOutput).toContain('Dev preview stopped')
54+
expect(cleanResult.exitCode, '‼️ Step 5 - app dev clean failed').toBe(0)
55+
expect(cleanOutput, '‼️ Step 5 - app dev clean: missing "Dev preview stopped" in output').toContain(
56+
'Dev preview stopped',
57+
)
5258
}
5359

5460
// Step 6: Deploy the primary app
@@ -68,15 +74,15 @@ test.describe('App basic flow (no extensions)', () => {
6874
{timeout: 5 * 60 * 1000},
6975
)
7076
const deployOutput = deployResult.stdout + deployResult.stderr
71-
expect(deployResult.exitCode, `deploy failed:\n${deployOutput}`).toBe(0)
77+
expect(deployResult.exitCode, '‼️ Step 6 - app deploy failed').toBe(0)
7278

7379
// Step 7: List versions and verify our tag appears
7480
const listResult = await cli.exec(['app', 'versions', 'list', '--path', appScaffold.appDir, '--json'], {
7581
timeout: 60 * 1000,
7682
})
7783
const listOutput = listResult.stdout + listResult.stderr
78-
expect(listResult.exitCode, `versions list failed:\n${listOutput}`).toBe(0)
79-
expect(listOutput).toContain(versionTag)
84+
expect(listResult.exitCode, '‼️ Step 7 - app versions list failed').toBe(0)
85+
expect(listOutput, `‼️ Step 7 - app versions list: missing version tag "${versionTag}"`).toContain(versionTag)
8086

8187
// Step 8: Config link to the secondary app
8288
// Pre-create a minimal TOML stub so getTomls() finds the secondary client ID and skips
@@ -94,9 +100,11 @@ test.describe('App basic flow (no extensions)', () => {
94100
['app', 'config', 'link', '--path', appScaffold.appDir, '--client-id', env.secondaryClientId],
95101
{env: {CI: '', SHOPIFY_FLAG_CLIENT_ID: undefined}},
96102
)
97-
await configLink.waitForOutput('is now linked to', 2 * 60 * 1000)
103+
await configLink.waitForOutput('is now linked to', 2 * 60 * 1000).catch((err: Error) => {
104+
throw new Error(`‼️ Step 8 - app config link failed\n${err.message}`)
105+
})
98106
const configLinkExitCode = await configLink.waitForExit(30_000)
99-
expect(configLinkExitCode, `config link failed:\n${configLink.getOutput()}`).toBe(0)
107+
expect(configLinkExitCode, '‼️ Step 8 - app config link failed').toBe(0)
100108

101109
// Step 9: Deploy to the secondary app using the linked config file
102110
const secondaryVersionTag = `e2e-secondary-v-${Date.now()}`
@@ -117,6 +125,6 @@ test.describe('App basic flow (no extensions)', () => {
117125
{timeout: 5 * 60 * 1000, env: {SHOPIFY_FLAG_CLIENT_ID: undefined}},
118126
)
119127
const secondaryDeployOutput = secondaryDeployResult.stdout + secondaryDeployResult.stderr
120-
expect(secondaryDeployResult.exitCode, `secondary deploy failed:\n${secondaryDeployOutput}`).toBe(0)
128+
expect(secondaryDeployResult.exitCode, '‼️ Step 9 - app deploy (secondary) failed').toBe(0)
121129
})
122130
})

0 commit comments

Comments
 (0)