Skip to content

Commit ca259c4

Browse files
wip(tests): add test for SyntaxError: 'import' and 'export' may appear only with 'sourceType: "module"'
1 parent 635d095 commit ca259c4

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/basic.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,33 @@ const { defaultFilesVue2, defaultFiles, createPage } = require('./testsTools.js'
567567

568568
await page.close();
569569
});
570+
571+
572+
test.only('error when using import/export in .js', async () => {
573+
574+
const { page, output } = await createPage({
575+
files: {
576+
...files,
577+
'/test.js': `
578+
export function test() {
579+
}
580+
`,
581+
'/component.vue': `
582+
<script>
583+
import './test.js'
584+
</script>
585+
<template>
586+
</template>
587+
`
588+
}
589+
});
590+
591+
await expect(output.filter(e => e.type === 'pageerror' && e.text).map(e => e.text)[0]).toMatch(`SyntaxError: 'import' and 'export' may appear only with 'sourceType: "module"'`);
592+
593+
await page.close();
594+
});
595+
596+
570597
});
571598

572599

0 commit comments

Comments
 (0)