Closed stephenwade closed 6 months ago
@stephenwade According to Vite docs, "Relative alias values will be used as-is and will not be resolved into file system paths". The following config works for me, tweaked from the repro. Note the path.resolve()
.
import { defineConfig, devices } from '@playwright/experimental-ct-react';
import path from 'path';
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: 'tests',
use: {
ctTemplateDir: 'tests',
ctViteConfig: {
resolve: {
// Match "paths" in tsconfig.json
alias: {
'~': path.resolve(__dirname, 'app'),
},
},
},
},
projects: [
{
name: 'chrome',
use: devices['Desktop Chrome'],
},
],
});
That works for me too. I wonder why it worked before? Maybe something to do with the upgrade to Vite 5?
Maybe something to do with the upgrade to Vite 5?
Most likely.
Version
1.42.1
Steps to reproduce
npm install
npm test
Expected behavior
The test runs.
Actual behavior
The test does not run. The following error is displayed:
Additional context
This only happens when both of these conditions are met:
ctViteConfig.resolve.alias
to add an alias path.I can't remove the
ctViteConfig
settings because my project usespaths
in the TSConfig file. My bundler understands the paths, but Vite in Playwright component testing doesn't.This was working fine in 1.41.2.
Environment