|
1 | 1 | import fs from 'node:fs'
|
2 | 2 | import path from 'node:path'
|
| 3 | +import { fileURLToPath } from 'node:url' |
3 | 4 | import { expect, test } from 'vitest'
|
4 |
| -import { isBuild, isWindows, page, testDir } from '~utils' |
| 5 | +import { isBuild, isWindows, page, testDir, viteTestUrl } from '~utils' |
5 | 6 |
|
6 | 7 | test('bom import', async () => {
|
7 | 8 | expect(await page.textContent('.utf8-bom')).toMatch('[success]')
|
@@ -202,6 +203,25 @@ test('Resolving from other package with imports field', async () => {
|
202 | 203 | expect(await page.textContent('.imports-pkg-slash')).toMatch('[success]')
|
203 | 204 | })
|
204 | 205 |
|
| 206 | +test('Resolve doesnt interrupt page request with trailing query and .css', async () => { |
| 207 | + await page.goto(viteTestUrl + '/?test.css') |
| 208 | + expect(await page.locator('vite-error-overlay').count()).toBe(0) |
| 209 | + expect(await page.textContent('h1')).toBe('Resolve') |
| 210 | +}) |
| 211 | + |
| 212 | +test.runIf(!isWindows)( |
| 213 | + 'Resolve doesnt interrupt page request that clashes with local project package.json', |
| 214 | + async () => { |
| 215 | + // Sometimes request path may point to a different project's package.json, but for testing |
| 216 | + // we point to Vite's own monorepo which always exists, and the package.json is not a library |
| 217 | + const pathToViteMonorepoRoot = new URL('../../../', import.meta.url) |
| 218 | + const urlPath = fileURLToPath(pathToViteMonorepoRoot).replace(/\/$/, '') |
| 219 | + await page.goto(viteTestUrl + urlPath) |
| 220 | + expect(await page.locator('vite-error-overlay').count()).toBe(0) |
| 221 | + expect(await page.textContent('h1')).toBe('Resolve') |
| 222 | + }, |
| 223 | +) |
| 224 | + |
205 | 225 | test.runIf(isBuild)('public dir is not copied', async () => {
|
206 | 226 | expect(
|
207 | 227 | fs.existsSync(path.resolve(testDir, 'dist/should-not-be-copied')),
|
|
0 commit comments