aboutsummaryrefslogtreecommitdiff
path: root/packages/astro/test/react-component.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/astro/test/react-component.test.js')
-rw-r--r--packages/astro/test/react-component.test.js22
1 files changed, 17 insertions, 5 deletions
diff --git a/packages/astro/test/react-component.test.js b/packages/astro/test/react-component.test.js
index 48c985be1..90b864925 100644
--- a/packages/astro/test/react-component.test.js
+++ b/packages/astro/test/react-component.test.js
@@ -72,11 +72,23 @@ React('Can load Vue', async () => {
assert.equal($('#vue-h2').text(), 'Hasta la vista, baby');
});
-React('Get good error message when react import is forgotten', async () => {
- const result = await runtime.load('/forgot-import');
+React('uses the new JSX transform', async () => {
+ const result = await runtime.load('/');
+ assert.ok(!result.error, `build error: ${result.error}`);
- assert.ok(result.error instanceof ReferenceError);
- assert.equal(result.error.message, 'React is not defined');
-});
+ // Grab the imports
+ const exp = /import\("(.+?)"\)/g;
+ let match, componentUrl;
+ while ((match = exp.exec(result.contents))) {
+ if (match[1].includes('Research.js')) {
+ componentUrl = match[1];
+ break;
+ }
+ }
+ const component = await runtime.load(componentUrl);
+ const jsxRuntime = component.imports.filter(i => i.specifier.includes('jsx-runtime'));
+
+ assert.ok(jsxRuntime, 'react/jsx-runtime is used for the component');
+})
React.run();