summaryrefslogtreecommitdiff
path: root/test/react-component.test.js
diff options
context:
space:
mode:
authorGravatar Matthew Phillips <matthew@matthewphillips.info> 2021-03-23 13:47:54 -0400
committerGravatar GitHub <noreply@github.com> 2021-03-23 13:47:54 -0400
commit854d0feb34f605c0fe3f5627a261e327164c449e (patch)
treec7d88676affbd271fd6304a73d98c149e265f042 /test/react-component.test.js
parent3f16550765cccee0de8f2f6e5451bf41aec13601 (diff)
downloadastro-854d0feb34f605c0fe3f5627a261e327164c449e.tar.gz
astro-854d0feb34f605c0fe3f5627a261e327164c449e.tar.zst
astro-854d0feb34f605c0fe3f5627a261e327164c449e.zip
Add support for React components. (#18)
* Add support for React components. This adds support for react components via a new `extensions` config in astro.config.mjs. In the future we can extend this to do things like look at the import statements, as Snowpack does. * Fix the tests
Diffstat (limited to 'test/react-component.test.js')
-rw-r--r--test/react-component.test.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/react-component.test.js b/test/react-component.test.js
new file mode 100644
index 000000000..0b6273922
--- /dev/null
+++ b/test/react-component.test.js
@@ -0,0 +1,40 @@
+import { suite } from 'uvu';
+import * as assert from 'uvu/assert';
+import { createRuntime } from '../lib/runtime.js';
+import { loadConfig } from '../lib/config.js';
+import { doc } from './test-utils.js';
+
+const React = suite('React Components');
+
+let runtime;
+
+React.before(async () => {
+ const astroConfig = await loadConfig(new URL('./fixtures/react-component', import.meta.url).pathname);
+
+ const logging = {
+ level: 'error',
+ dest: process.stderr
+ };
+
+ try {
+ runtime = await createRuntime(astroConfig, logging);
+ } catch(err) {
+ console.error(err);
+ throw err;
+ }
+});
+
+React.after(async () => {
+ await runtime.shutdown();
+});
+
+React('Can load hmx page', async () => {
+ const result = await runtime.load('/');
+
+ assert.equal(result.statusCode, 200);
+
+ const $ = doc(result.contents);
+ assert.equal($('h2').text(), 'Hello world!');
+});
+
+React.run(); \ No newline at end of file