summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/astro-doctype.test.js3
-rw-r--r--test/astro-markdown.test.js3
-rw-r--r--test/astro-styles-ssr.test.js12
-rw-r--r--test/helpers.js3
-rw-r--r--test/react-component.test.js3
-rw-r--r--test/snowpack-integration.test.js11
6 files changed, 24 insertions, 11 deletions
diff --git a/test/astro-doctype.test.js b/test/astro-doctype.test.js
index c71aee1de..b6c37c3d7 100644
--- a/test/astro-doctype.test.js
+++ b/test/astro-doctype.test.js
@@ -1,3 +1,4 @@
+import { fileURLToPath } from 'url';
import { suite } from 'uvu';
import * as assert from 'uvu/assert';
import { loadConfig } from '../lib/config.js';
@@ -9,7 +10,7 @@ let runtime, setupError;
DType.before(async () => {
try {
- const astroConfig = await loadConfig(new URL('./fixtures/astro-doctype', import.meta.url).pathname);
+ const astroConfig = await loadConfig(fileURLToPath(new URL('./fixtures/astro-doctype', import.meta.url)));
const logging = {
level: 'error',
diff --git a/test/astro-markdown.test.js b/test/astro-markdown.test.js
index 1651a0a6f..4d6a4f438 100644
--- a/test/astro-markdown.test.js
+++ b/test/astro-markdown.test.js
@@ -1,5 +1,6 @@
import { existsSync, promises as fsPromises } from 'fs';
import { join } from 'path';
+import { fileURLToPath } from 'url';
import { suite } from 'uvu';
import * as assert from 'uvu/assert';
import { createRuntime } from '../lib/runtime.js';
@@ -14,7 +15,7 @@ const Markdown = suite('Astro Markdown');
let runtime, setupError, fixturePath, astroConfig;
Markdown.before(async () => {
- fixturePath = new URL('./fixtures/astro-markdown', import.meta.url).pathname;
+ fixturePath = fileURLToPath(new URL('./fixtures/astro-markdown', import.meta.url));
astroConfig = await loadConfig(fixturePath);
diff --git a/test/astro-styles-ssr.test.js b/test/astro-styles-ssr.test.js
index af3cccd3b..0f113c128 100644
--- a/test/astro-styles-ssr.test.js
+++ b/test/astro-styles-ssr.test.js
@@ -42,14 +42,20 @@ StylesSSR('Has correct CSS classes', async ({ runtime }) => {
const MUST_HAVE_CLASSES = {
'#react-css': 'react-title',
'#vue-css': 'vue-title',
- '#vue-css-modules': '_title_1gi0u_2', // ⚠️ may be flaky
+ '#vue-css-modules': 'title', // ⚠️ this is the inverse
'#vue-scoped': 'vue-title', // also has data-v-* property
'#svelte-scoped': 'svelte-title', // also has additional class
};
for (const [selector, className] of Object.entries(MUST_HAVE_CLASSES)) {
const el = $(selector);
- assert.ok(el.attr('class').includes(className));
+ if (selector === '#vue-css-modules') {
+ // this will generate differently on Unix vs Windows. Here we simply test that it has transformed
+ assert.not.equal(el.attr('class'), 'title');
+ } else {
+ // if this is not a CSS module, it should remain as expected
+ assert.ok(el.attr('class').includes(className));
+ }
// add’l test: Vue Scoped styles should have data-v-* attribute
if (selector === '#vue-scoped') {
@@ -81,7 +87,7 @@ StylesSSR('CSS Module support in .astro', async ({ runtime }) => {
})
);
- assert.equal(css, `.wrapper${scopedClass}{margin-left:auto;margin-right:auto;max-width:1200px}`);
+ assert.match(css, `.wrapper${scopedClass}{margin-left:auto;margin-right:auto;max-width:1200px}`);
// test 2: element received .astro-XXXXXX class (this selector will succeed if transformed correctly)
const wrapper = $(`.wrapper${scopedClass}`);
diff --git a/test/helpers.js b/test/helpers.js
index 764208c17..aa2e31714 100644
--- a/test/helpers.js
+++ b/test/helpers.js
@@ -1,3 +1,4 @@
+import { fileURLToPath } from 'url';
import { createRuntime } from '../lib/runtime.js';
import { loadConfig } from '../lib/config.js';
import * as assert from 'uvu/assert';
@@ -6,7 +7,7 @@ export function setup(Suite, fixturePath) {
let runtime, setupError;
Suite.before(async (context) => {
- const astroConfig = await loadConfig(new URL(fixturePath, import.meta.url).pathname);
+ const astroConfig = await loadConfig(fileURLToPath(new URL(fixturePath, import.meta.url)));
const logging = {
level: 'error',
diff --git a/test/react-component.test.js b/test/react-component.test.js
index ea0cb51b7..7de92cb0a 100644
--- a/test/react-component.test.js
+++ b/test/react-component.test.js
@@ -1,3 +1,4 @@
+import { fileURLToPath } from 'url';
import { suite } from 'uvu';
import * as assert from 'uvu/assert';
import { createRuntime } from '../lib/runtime.js';
@@ -9,7 +10,7 @@ const React = suite('React Components');
let runtime, setupError;
React.before(async () => {
- const astroConfig = await loadConfig(new URL('./fixtures/react-component', import.meta.url).pathname);
+ const astroConfig = await loadConfig(fileURLToPath(new URL('./fixtures/react-component', import.meta.url)));
const logging = {
level: 'error',
diff --git a/test/snowpack-integration.test.js b/test/snowpack-integration.test.js
index 2583aab5e..9a29bf16e 100644
--- a/test/snowpack-integration.test.js
+++ b/test/snowpack-integration.test.js
@@ -1,3 +1,4 @@
+import { fileURLToPath } from 'url';
import { suite } from 'uvu';
import * as assert from 'uvu/assert';
import { createRuntime } from '../lib/runtime.js';
@@ -15,9 +16,9 @@ let runtime, cwd, setupError;
SnowpackDev.before(async () => {
// Bug: Snowpack config is still loaded relative to the current working directory.
cwd = process.cwd();
- process.chdir(new URL('../examples/snowpack/', import.meta.url).pathname);
+ process.chdir(fileURLToPath(new URL('../examples/snowpack/', import.meta.url)));
- const astroConfig = await loadConfig(new URL('../examples/snowpack', import.meta.url).pathname);
+ const astroConfig = await loadConfig(fileURLToPath(new URL('../examples/snowpack', import.meta.url)));
const logging = {
level: 'error',
@@ -53,9 +54,11 @@ async function* allPageFiles(root) {
/** create an iterator for all pages and yield the relative paths */
async function* allPages(root) {
for await (let fileURL of allPageFiles(root)) {
- let bare = fileURL.pathname.replace(/\.(astro|md)$/, '').replace(/index$/, '');
+ let bare = fileURLToPath(fileURL)
+ .replace(/\.(astro|md)$/, '')
+ .replace(/index$/, '');
- yield '/' + pathRelative(root.pathname, bare);
+ yield '/' + pathRelative(fileURLToPath(root), bare);
}
}