0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-02-17 22:44:24 -05:00

Late test should only run in SSR

This commit is contained in:
Matthew Phillips 2023-05-19 15:42:18 -04:00
parent ab0539b951
commit 83ed3669be
2 changed files with 6 additions and 2 deletions

View file

@ -1,5 +1,6 @@
--- ---
import Redirect from '../components/redirect.astro'; import Redirect from '../components/redirect.astro';
const staticMode = import.meta.env.STATIC_MODE;
--- ---
<html> <html>
<head> <head>
@ -7,6 +8,8 @@ import Redirect from '../components/redirect.astro';
</head> </head>
<body> <body>
<h1>Testing</h1> <h1>Testing</h1>
<Redirect /> { !staticMode ? (
<Redirect />
) : <div></div>}
</body> </body>
</html> </html>

View file

@ -29,7 +29,7 @@ describe('Astro.redirect', () => {
const request = new Request('http://example.com/late'); const request = new Request('http://example.com/late');
const response = await app.render(request); const response = await app.render(request);
try { try {
const text = await response.text(); await response.text();
expect(false).to.equal(true); expect(false).to.equal(true);
} catch (e) { } catch (e) {
expect(e.message).to.equal( expect(e.message).to.equal(
@ -41,6 +41,7 @@ describe('Astro.redirect', () => {
describe('output: "static"', () => { describe('output: "static"', () => {
before(async () => { before(async () => {
process.env.STATIC_MODE = true;
fixture = await loadFixture({ fixture = await loadFixture({
root: './fixtures/ssr-redirect/', root: './fixtures/ssr-redirect/',
output: 'static', output: 'static',