From 991c30a72a7fdde5857870be7be1482d466dbb07 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Thu, 23 Dec 2021 15:24:02 -0500 Subject: [PATCH] Don't run dev mode tests on windows (#2262) * Don't run dev mode tests on windows * Debugging * chore(lint): Prettier fix * remove the throw * Skip a different way * chore(lint): Prettier fix * Skip the error test on windows too * chore(lint): Prettier fix * Move the after into the closure * chore(lint): Prettier fix Co-authored-by: github-actions[bot] --- packages/astro/test/errors.test.js | 40 ++++++++++---------- packages/astro/test/react-component.test.js | 4 +- packages/astro/test/solid-component.test.js | 4 +- packages/astro/test/svelte-component.test.js | 4 +- packages/astro/test/test-utils.js | 3 ++ packages/astro/test/vue-component.test.js | 4 +- 6 files changed, 36 insertions(+), 23 deletions(-) diff --git a/packages/astro/test/errors.test.js b/packages/astro/test/errors.test.js index 32848851c..d85cb9e04 100644 --- a/packages/astro/test/errors.test.js +++ b/packages/astro/test/errors.test.js @@ -1,21 +1,27 @@ import { expect } from 'chai'; -import { loadFixture } from './test-utils.js'; - -let fixture; -let devServer; - -before(async () => { - fixture = await loadFixture({ - projectRoot: './fixtures/errors', - renderers: ['@astrojs/renderer-preact', '@astrojs/renderer-react', '@astrojs/renderer-solid', '@astrojs/renderer-svelte', '@astrojs/renderer-vue'], - vite: { - optimizeDeps: false, // necessary to prevent Vite throwing on bad files - }, - }); - devServer = await fixture.startDevServer(); -}); +import { isWindows, loadFixture } from './test-utils.js'; describe('Error display', () => { + if (isWindows) return; + + let fixture; + let devServer; + + before(async () => { + fixture = await loadFixture({ + projectRoot: './fixtures/errors', + renderers: ['@astrojs/renderer-preact', '@astrojs/renderer-react', '@astrojs/renderer-solid', '@astrojs/renderer-svelte', '@astrojs/renderer-vue'], + vite: { + optimizeDeps: false, // necessary to prevent Vite throwing on bad files + }, + }); + devServer = await fixture.startDevServer(); + }); + + after(async () => { + await devServer.stop(); + }); + describe('Astro', () => { it('syntax error in template', async () => { const res = await fixture.fetch('/astro-syntax-error'); @@ -200,7 +206,3 @@ describe('Error display', () => { }); }); }); - -after(async () => { - await devServer.stop(); -}); diff --git a/packages/astro/test/react-component.test.js b/packages/astro/test/react-component.test.js index 4e237508c..fcfab827e 100644 --- a/packages/astro/test/react-component.test.js +++ b/packages/astro/test/react-component.test.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; import cheerio from 'cheerio'; -import { loadFixture } from './test-utils.js'; +import { isWindows, loadFixture } from './test-utils.js'; let fixture; @@ -75,6 +75,8 @@ describe('React Components', () => { }); }); + if (isWindows) return; + describe('dev', () => { let devServer; diff --git a/packages/astro/test/solid-component.test.js b/packages/astro/test/solid-component.test.js index fa7172d31..8b76e9f6f 100644 --- a/packages/astro/test/solid-component.test.js +++ b/packages/astro/test/solid-component.test.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; import cheerio from 'cheerio'; -import { loadFixture } from './test-utils.js'; +import { isWindows, loadFixture } from './test-utils.js'; describe('Solid component', () => { let fixture; @@ -29,6 +29,8 @@ describe('Solid component', () => { }); }); + if (isWindows) return; + describe('dev', () => { let devServer; diff --git a/packages/astro/test/svelte-component.test.js b/packages/astro/test/svelte-component.test.js index ef350af4d..edf6e3965 100644 --- a/packages/astro/test/svelte-component.test.js +++ b/packages/astro/test/svelte-component.test.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; import cheerio from 'cheerio'; -import { loadFixture } from './test-utils.js'; +import { isWindows, loadFixture } from './test-utils.js'; describe('Svelte component', () => { let fixture; @@ -28,6 +28,8 @@ describe('Svelte component', () => { }); }); + if (isWindows) return; + describe('dev', () => { let devServer; diff --git a/packages/astro/test/test-utils.js b/packages/astro/test/test-utils.js index 49775c3b4..8d8ba9e2c 100644 --- a/packages/astro/test/test-utils.js +++ b/packages/astro/test/test-utils.js @@ -6,6 +6,7 @@ import { loadConfig } from '../dist/core/config.js'; import dev from '../dist/core/dev/index.js'; import build from '../dist/core/build/index.js'; import preview from '../dist/core/preview/index.js'; +import os from 'os'; /** * @typedef {import('node-fetch').Response} Response * @typedef {import('../src/core/dev/index').DevServer} DevServer @@ -109,3 +110,5 @@ export function cli(/** @type {string[]} */ ...args) { return spawned; } + +export const isWindows = os.platform() === 'win32'; diff --git a/packages/astro/test/vue-component.test.js b/packages/astro/test/vue-component.test.js index a02a85a3f..9cad2ccc3 100644 --- a/packages/astro/test/vue-component.test.js +++ b/packages/astro/test/vue-component.test.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; import cheerio from 'cheerio'; -import { loadFixture } from './test-utils.js'; +import { isWindows, loadFixture } from './test-utils.js'; describe('Vue component', () => { let fixture; @@ -43,6 +43,8 @@ describe('Vue component', () => { }); }); + if (isWindows) return; + describe('dev', () => { let devServer;