Skip to content

Commit

Permalink
Add test for module not found error
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed Aug 4, 2020
1 parent 668cc6a commit 0c3de1a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/acceptance/ReactRefreshLogBox.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,35 @@ test('unterminated JSX', async () => {
await cleanup()
})

test('Module not found', async () => {
const [session, cleanup] = await sandbox()

await session.patch(
'index.js',
`
import Comp from 'b'
export default () => {
return (
<div>
<Comp>lol</Comp>
</div>
)
}
`
)

expect(await session.hasRedbox(true)).toBe(true)

const source = await session.getRedboxSource()
expect(source).toMatchInlineSnapshot(`
"./index.js
Module not found: Can't resolve 'b' in '${session.sandboxDirectory}'"
`)

await cleanup()
})

test('conversion to class component (1)', async () => {
const [session, cleanup] = await sandbox()

Expand Down
1 change: 1 addition & 0 deletions test/acceptance/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export async function sandbox(id = nanoid(), initialFiles = new Map()) {

return [
{
sandboxDirectory,
async write(fileName, content) {
// Update the file on filesystem
const fullFileName = path.join(sandboxDirectory, fileName)
Expand Down

0 comments on commit 0c3de1a

Please sign in to comment.