Skip to content

Commit 33914d6

Browse files
committed
TEMP - Testing instructions
1 parent 3ccf635 commit 33914d6

File tree

3 files changed

+235
-0
lines changed

3 files changed

+235
-0
lines changed

packages/app/TEST_INSTRUCTIONS.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Testing Instructions for PR - Fix Bundling Errors Display (Issue #2092)
2+
3+
## Background
4+
This PR fixes issue #2092 where bundling errors were not visible without using the `--verbose` flag. The fix ensures that when UI extensions or web pixels fail to bundle, the error details are displayed in the command output.
5+
6+
## Test Files Provided
7+
8+
1. **`test-bundling-error-example.ts`** - A file with intentional syntax and compilation errors
9+
2. **`manual-test-error-visibility.ts`** - A test script that verifies errors are displayed properly
10+
11+
## How to Test
12+
13+
### Option 1: Run the Manual Test Script
14+
15+
```bash
16+
cd packages/app
17+
pnpm tsx manual-test-error-visibility.ts
18+
```
19+
20+
This script will:
21+
- Try to bundle code with various types of errors
22+
- Verify that errors are displayed to stderr
23+
- Check that the error output contains proper error markers and details
24+
- Test both inline errors and file import errors
25+
26+
**Expected output:**
27+
- You should see detailed error messages displayed
28+
- The test should report "✅ SUCCESS: Issue #2092 is fixed"
29+
30+
### Option 2: Test with Real Extension
31+
32+
1. Create a UI extension with an intentional error:
33+
```bash
34+
cd packages/app
35+
# Edit any extension file to include a syntax error, for example:
36+
# - Remove a closing parenthesis
37+
# - Import from a non-existent module
38+
# - Use an undefined variable
39+
```
40+
41+
2. Run the build command:
42+
```bash
43+
pnpm shopify app build
44+
```
45+
46+
**Before this fix:** You would see a generic error without details unless using `--verbose`
47+
**After this fix:** You should see the actual bundling errors with details about what went wrong
48+
49+
### Option 3: Run Existing Tests
50+
51+
The existing test suite already verifies this behavior:
52+
```bash
53+
cd packages/app
54+
pnpm test src/cli/services/extensions/bundle.test.ts
55+
```
56+
57+
Look for the test: "throws error when bundling fails and displays formatted errors"
58+
59+
## What to Verify
60+
61+
1. ✅ When bundling fails, error details are shown without needing `--verbose`
62+
2. ✅ Error output includes `[ERROR]` markers
63+
3. ✅ Error messages include specific details about what failed (file, line, error type)
64+
4. ✅ The build process still fails appropriately when errors occur
65+
5. ✅ The simplified code maintains the same functionality with less complexity
66+
67+
## Code Changes Summary
68+
69+
The PR simplifies the error handling while maintaining the fix for #2092:
70+
- Removed unnecessary `ErrorWithErrors` interface
71+
- Simplified error catching logic in `extension.ts`
72+
- Kept the essential `onResult` function that writes errors to stderr
73+
- All error display functionality remains intact
74+
75+
## Cleanup
76+
77+
After testing, you can remove the test files:
78+
```bash
79+
rm test-bundling-error-example.ts manual-test-error-visibility.ts TEST_INSTRUCTIONS.md
80+
```
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
// Manual test script to verify bundling error visibility (issue #2092)
2+
import {bundleExtension} from './src/cli/services/extensions/bundle.js'
3+
import {Writable} from 'stream'
4+
import {resolve} from 'path'
5+
6+
console.log('Testing bundling error visibility for issue #2092...\n');
7+
8+
// Capture stderr output
9+
let stderrOutput = '';
10+
const stderr = new Writable({
11+
write(chunk, _encoding, callback) {
12+
const text = chunk.toString();
13+
stderrOutput += text;
14+
// Also write to real stderr so we can see it
15+
process.stderr.write(chunk);
16+
callback();
17+
},
18+
});
19+
20+
// Stdout for any warnings
21+
const stdout = new Writable({
22+
write(chunk, _encoding, callback) {
23+
process.stdout.write(chunk);
24+
callback();
25+
},
26+
});
27+
28+
async function testBundlingErrors() {
29+
console.log('1. Testing with syntax errors in the code...\n');
30+
31+
try {
32+
await bundleExtension({
33+
env: {},
34+
outputPath: '/tmp/test-output.js',
35+
minify: false,
36+
environment: 'development',
37+
stdin: {
38+
contents: `
39+
// This code has intentional errors
40+
import { nonExistent } from 'missing-module';
41+
42+
// Syntax error: missing closing parenthesis
43+
console.log('Hello world'
44+
45+
// Reference error
46+
const x = undefinedVariable;
47+
48+
// Type error
49+
const num: number = "not a number";
50+
`,
51+
resolveDir: process.cwd(),
52+
loader: 'tsx',
53+
},
54+
stdout,
55+
stderr,
56+
});
57+
58+
console.log('\n❌ ERROR: Bundling should have failed but it succeeded!');
59+
} catch (error) {
60+
console.log('\n✅ Bundling failed as expected');
61+
console.log(` Error message: ${error.message}`);
62+
}
63+
64+
console.log('\n2. Checking if errors were displayed to stderr...\n');
65+
66+
if (stderrOutput.trim()) {
67+
console.log('✅ Errors were displayed without --verbose flag:');
68+
console.log(' Total error output length:', stderrOutput.length, 'characters');
69+
70+
// Check for specific error indicators
71+
const hasErrorMarker = /\[ERROR\]/.test(stderrOutput);
72+
const hasErrorDetails = stderrOutput.length > 50; // Should have substantial error details
73+
74+
console.log(` Contains [ERROR] marker: ${hasErrorMarker ? '✅' : '❌'}`);
75+
console.log(` Has detailed error info: ${hasErrorDetails ? '✅' : '❌'}`);
76+
77+
if (!hasErrorMarker || !hasErrorDetails) {
78+
console.log('\n❌ ERROR: Error output does not contain expected details');
79+
console.log('This means issue #2092 is NOT fixed!');
80+
} else {
81+
console.log('\n✅ SUCCESS: Issue #2092 is fixed - errors are visible without --verbose');
82+
}
83+
} else {
84+
console.log('❌ ERROR: No errors were written to stderr!');
85+
console.log('This means issue #2092 is NOT fixed!');
86+
}
87+
88+
console.log('\n3. Testing with file import errors...\n');
89+
90+
// Reset stderr output
91+
stderrOutput = '';
92+
93+
try {
94+
await bundleExtension({
95+
env: {},
96+
outputPath: '/tmp/test-output2.js',
97+
minify: false,
98+
environment: 'development',
99+
stdin: {
100+
contents: `import './test-bundling-error-example.ts';`,
101+
resolveDir: process.cwd(),
102+
loader: 'tsx',
103+
},
104+
stdout,
105+
stderr,
106+
});
107+
108+
console.log('\n❌ ERROR: Bundling should have failed but it succeeded!');
109+
} catch (error) {
110+
console.log('✅ Bundling failed as expected when importing error file');
111+
112+
if (stderrOutput.trim()) {
113+
console.log('✅ Import errors were also displayed properly');
114+
} else {
115+
console.log('❌ ERROR: Import errors were not displayed!');
116+
}
117+
}
118+
}
119+
120+
// Run the test
121+
testBundlingErrors().then(() => {
122+
console.log('\n--- Test complete ---\n');
123+
process.exit(0);
124+
}).catch((error) => {
125+
console.error('\nUnexpected error during test:', error);
126+
process.exit(1);
127+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Test file with intentional errors to verify bundling error visibility
2+
// This file is used to test that issue #2092 is resolved
3+
4+
// Error 1: Import from non-existent module
5+
import { someFunction } from 'non-existent-module';
6+
7+
// Error 2: Syntax error - missing closing parenthesis
8+
console.log('This has a syntax error'
9+
10+
// Error 3: Reference error - undefined variable
11+
const config = {
12+
apiKey: undefinedVariable,
13+
setting: true
14+
};
15+
16+
// Error 4: Type error in TypeScript
17+
const numberValue: number = "this should be a number";
18+
19+
// Error 5: Missing closing brace
20+
function brokenFunction() {
21+
if (true) {
22+
console.log('Missing closing brace');
23+
// Missing closing brace here
24+
25+
export default function() {
26+
someFunction();
27+
return config;
28+
}

0 commit comments

Comments
 (0)