-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(test): resolve imports correctly in tests (#6478)
**Problem:** We have a major problem in tests where code like `import X from './file1.js'` is actually trying to resolve it to `test.js/file1.js` and fails. It happens due to `resolveTestFiles` calling: ```ts path.normalize(`${importOrigin}/${normalizedName}`) ``` creating - for example - imports like `'test.js/app.js'` that weren't found. The function returned an error value of "Test error, the dumbResolveFn did not know about this file: 'test.js/app.js'", but no one checked it down the road, causing the valid paths generation to ignore its contents completely. The tests were asserting an incorrect snapshot, with partial, incorrect valid paths, and that's the reason they passed. **Fix:** - Fix `resolveTestFiles` so it will be closer to our real code, using `path.parse` to get the directory of the import origin - Fix the tests snapshots to assert a correct expected result - Log the error (throwing it seemed too obtrusive since some tests might actually check for missing file functionality) **Manual Tests:** I hereby swear that: - [x] I opened a hydrogen project and it loaded - [x] I could navigate to various routes in Play mode
- Loading branch information
Showing
3 changed files
with
31 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters