import { expect } from 'chai'; import { load as cheerioLoad } from 'cheerio'; import { isWindows, loadFixture } from '../../../astro/test/test-utils.js'; let fixture; describe('React Components', () => { before(async () => { fixture = await loadFixture({ root: new URL('./fixtures/react-component/', import.meta.url), }); }); describe('build', () => { before(async () => { await fixture.build(); }); it('Can load React', async () => { const html = await fixture.readFile('/index.html'); const $ = cheerioLoad(html); // test 1: basic component renders expect($('#react-static').text()).to.equal('Hello static!'); // test 2: no reactroot expect($('#react-static').attr('data-reactroot')).to.equal(undefined); // test 3: Can use function components expect($('#arrow-fn-component')).to.have.lengthOf(1); // test 4: Can use spread for components expect($('#component-spread-props')).to.have.lengthOf(1); // test 5: spread props renders expect($('#component-spread-props').text(), 'Hello world!'); // test 6: Can use TS components expect($('.ts-component')).to.have.lengthOf(1); // test 7: Can use Pure components expect($('#pure')).to.have.lengthOf(1); // test 8: Check number of islands expect($('astro-island[uid]')).to.have.lengthOf(9); // test 9: Check island deduplication const uniqueRootUIDs = new Set($('astro-island').map((i, el) => $(el).attr('uid'))); expect(uniqueRootUIDs.size).to.equal(8); // test 10: Should properly render children passed as props const islandsWithChildren = $('.with-children'); expect(islandsWithChildren).to.have.lengthOf(2); expect($(islandsWithChildren[0]).html()).to.equal( $(islandsWithChildren[1]).find('astro-slot').html() ); // test 11: Should generate unique React.useId per island const islandsWithId = $('.react-use-id'); expect(islandsWithId).to.have.lengthOf(2); expect($(islandsWithId[0]).attr('id')).to.not.equal($(islandsWithId[1]).attr('id')); }); it('Can load Vue', async () => { const html = await fixture.readFile('/index.html'); const $ = cheerioLoad(html); expect($('#vue-h2').text()).to.equal('Hasta la vista, baby'); }); it('Can use a pragma comment', async () => { const html = await fixture.readFile('/pragma-comment/index.html'); const $ = cheerioLoad(html); // test 1: rendered the PragmaComment component expect($('.pragma-comment')).to.have.lengthOf(2); }); // TODO: is this still a relevant test? it.skip('Includes reactroot on hydrating components', async () => { const html = await fixture.readFile('/index.html'); const $ = cheerioLoad(html); const div = $('#research'); // test 1: has the hydration attr expect(div.attr('data-reactroot')).to.be.ok; // test 2: renders correctly expect(div.html()).to.equal('foo bar 1'); }); it('Can load Suspense-using components', async () => { const html = await fixture.readFile('/suspense/index.html'); const $ = cheerioLoad(html); expect($('#client #lazy')).to.have.lengthOf(1); expect($('#server #lazy')).to.have.lengthOf(1); }); it('Can pass through props with cloneElement', async () => { const html = await fixture.readFile('/index.html'); const $ = cheerioLoad(html); expect($('#cloned').text()).to.equal('Cloned With Props'); }); it('Children are parsed as React components, can be manipulated', async () => { const html = await fixture.readFile('/children/index.html'); const $ = cheerioLoad(html); expect($('.with-children-count').text()).to.equal('2'); }); }); if (isWindows) return; describe('dev', () => { /** @type {import('../../../astro/test/test-utils.js').Fixture} */ let devServer; before(async () => { devServer = await fixture.startDevServer(); }); after(async () => { await devServer.stop(); }); it('scripts proxy correctly', async () => { const html = await fixture.fetch('/').then((res) => res.text()); const $ = cheerioLoad(html); for (const script of $('script').toArray()) { const { src } = script.attribs; if (!src) continue; expect((await fixture.fetch(src)).status, `404: ${src}`).to.equal(200); } }); // TODO: move this to separate dev test? it.skip('Throws helpful error message on window SSR', async () => { const html = await fixture.fetch('/window/index.html'); expect(html).to.include( `[/window] The window object is not available during server-side rendering (SSR). Try using \`import.meta.env.SSR\` to write SSR-friendly code. https://docs.astro.build/reference/api-reference/#importmeta` ); }); // In moving over to Vite, the jsx-runtime import is now obscured. TODO: update the method of finding this. it.skip('uses the new JSX transform', async () => { const html = await fixture.fetch('/index.html'); // Grab the imports const exp = /import\("(.+?)"\)/g; let match, componentUrl; while ((match = exp.exec(html))) { if (match[1].includes('Research.js')) { componentUrl = match[1]; break; } } const component = await fixture.readFile(componentUrl); const jsxRuntime = component.imports.filter((i) => i.specifier.includes('jsx-runtime')); // test 1: react/jsx-runtime is used for the component expect(jsxRuntime).to.be.ok; }); it('When a nested component throws it does not crash the server', async () => { const res = await fixture.fetch('/error-rendering'); await res.arrayBuffer(); }); }); }); value='feat/all-fragments'>feat/all-fragments Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
path: root/examples/framework-alpine/astro.config.mjs (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2022-03-01[ci] update smoke tests (remote) (#2690)Gravatar github-actions[bot] 2-6/+4
2022-03-01[ci] collect statsGravatar FredKSchott 1-0/+1
2022-02-28[ci] update smoke tests (remote) (#2686)Gravatar github-actions[bot] 96-3363/+8217
2022-02-28[ci] update lockfile (#2687)Gravatar Fred K. Schott 1-101/+75
2022-03-01[ci] collect statsGravatar FredKSchott 1-0/+1
2022-02-28update ci branch nameGravatar Fred K. Schott 1-0/+2
2022-02-28Make smoke tests more deterministic (#2618)Gravatar Fred K. Schott 336-147/+34315
2022-02-28[ci] yarn formatGravatar natemoo-re 1-20/+20
2022-02-28[ci] release (#2683)astro@0.23.3Gravatar github-actions[bot] 31-54/+55
2022-02-28Fix typo (#2674)Gravatar Robin Millette 1-1/+1
2022-02-28[ci] update lockfile (#2676)Gravatar Fred K. Schott 1-6/+6
2022-02-28fix(runtime): do not render empty Fragment (#2667)Gravatar Mateus Esdras 1-0/+3
2022-02-28fix(hmr): HMR regression related to .astro updates (#2681)Gravatar Nate Moore 6-7/+24
2022-02-28Fix HTMLElement expression warning (#2675)Gravatar Jonathan Neal 1-1/+1
2022-02-28[ci] collect statsGravatar FredKSchott 1-0/+1
2022-02-27[ci] update lockfile (#2668)Gravatar Fred K. Schott 1-80/+80
2022-02-27[ci] collect statsGravatar FredKSchott 1-0/+1
2022-02-26[ci] collect statsGravatar FredKSchott 1-0/+1
2022-02-25[ci] yarn formatGravatar natemoo-re 1-20/+20
2022-02-25[ci] release (#2666)astro@0.23.2Gravatar github-actions[bot] 32-59/+57
2022-02-25[ci] yarn formatGravatar natemoo-re 2-12/+6
2022-02-25fix astro scoping of "@import" inside of style tags (#2656)Gravatar Fred K. Schott 3-6/+35
2022-02-25[ci] update lockfile (#2659)Gravatar Fred K. Schott 1-20/+20
2022-02-25feat: improve third-party Astro package compatability (#2665)Gravatar Nate Moore 3-6/+100
2022-02-25get new example working during buildGravatar Fred K. Schott 4-16/+21
2022-02-25[ci] yarn formatGravatar FredKSchott 1-7/+6
2022-02-25Add Non-HTML Pages example (#2637)Gravatar Joel Kuzmarski 11-0/+136
2022-02-25[ci] collect statsGravatar FredKSchott 1-0/+1
2022-02-24[ci] yarn formatGravatar natemoo-re 2-24/+24
2022-02-24[ci] release (#2641)astro@0.23.1@astrojs/markdown-remark@0.6.2Gravatar github-actions[bot] 38-90/+81
2022-02-24ensure utf8 encoding when serving html (#2654)Gravatar Fred K. Schott 3-4/+9
2022-02-24fix(core): Issue #2625. error with process.env.LANG larger than 5 (#2645)Gravatar Javier Cortés 2-1/+6
2022-02-24[ci] update lockfile (#2646)Gravatar Fred K. Schott 1-130/+124
2022-02-24chore: upgrade compiler (#2653)Gravatar Nate Moore 3-11/+11
2022-02-24[ci] yarn formatGravatar natemoo-re 2-5/+5
2022-02-24Add fine-grained HMR support (#2649)Gravatar Nate Moore 7-36/+37
2022-02-24[ci] collect statsGravatar FredKSchott 1-0/+1
2022-02-23Fixed incorrect types and imports (#2630)Gravatar Juan Martín Seery 27-35/+37
2022-02-23Add sass dev dep to blog-multiple-authors example (#2643)Gravatar Joel Kuzmarski 1-1/+2
2022-02-23Fix(component): align starting position in Markdown slot (#2631)Gravatar Shinobu Hayashi 4-6/+61
2022-02-23[ci] yarn formatGravatar matthewp 1-1/+1
2022-02-23Run all smoke tests with the static build (#2609)Gravatar Matthew Phillips 2-26/+32
2022-02-23[ci] collect statsGravatar FredKSchott 1-0/+1
2022-02-22[ci] update lockfile (#2624)Gravatar Fred K. Schott 1-171/+201
2022-02-22Fixed shiki import to work with "type": "module" (#2628)Gravatar Juan Martín Seery 3-5/+13