@@ -2,28 +2,27 @@ import {resolve} from 'node:path';
22
33import type { PlaywrightTestConfig } from '@playwright/experimental-ct-react' ;
44import { defineConfig , devices } from '@playwright/experimental-ct-react' ;
5+ import type { InlineConfig } from 'vite' ; // eslint-disable-line import/no-extraneous-dependencies
56
6- function pathFromRoot ( p : string ) {
7+ import tsConfig from '../../tsconfig.json' ;
8+
9+ const pathFromRoot = ( p : string ) => {
710 return resolve ( __dirname , '../' , p ) ;
8- }
11+ } ;
912
10- const reporter : PlaywrightTestConfig [ 'reporter' ] = [ ] ;
13+ const aliasesFromTsConf = ( ( ) => {
14+ const baseUrl = resolve ( __dirname , '..' , '..' , tsConfig . compilerOptions . baseUrl ) ;
15+ const paths = tsConfig . compilerOptions . paths ;
1116
12- reporter . push (
13- [ 'list' ] ,
14- [
15- 'html' ,
16- {
17- open : process . env . CI ? 'never' : 'on-failure' ,
18- outputFolder : resolve (
19- process . cwd ( ) ,
20- process . env . IS_DOCKER ? 'playwright-report-docker' : 'playwright-report' ,
21- ) ,
22- } ,
23- ] ,
24- ) ;
17+ return Object . entries ( paths ) . reduce < Record < string , string > > ( ( acc , [ key , value ] ) => {
18+ const cleanKey = key . replace ( '/*' , '' ) ;
19+ const cleanValue = value [ 0 ] . replace ( '/*' , '' ) ;
20+ acc [ cleanKey ] = resolve ( baseUrl , cleanValue ) ;
21+ return acc ;
22+ } , { } ) ;
23+ } ) ( ) ;
2524
26- const ctViteConfig = {
25+ const ctViteConfig : InlineConfig = {
2726 css : {
2827 preprocessorOptions : {
2928 scss : {
@@ -33,11 +32,7 @@ const ctViteConfig = {
3332 } ,
3433 resolve : {
3534 alias : {
36- '#core' : resolve ( __dirname , '../../src/core' ) ,
37- '#cm' : resolve ( __dirname , '../../src/cm' ) ,
38- '#pm' : resolve ( __dirname , '../../src/pm' ) ,
39- src : resolve ( __dirname , '../../src' ) ,
40- playwright : resolve ( __dirname ) ,
35+ ...aliasesFromTsConf ,
4136 '~@gravity-ui/uikit/styles/mixins' : '@gravity-ui/uikit/styles/mixins' ,
4237 } ,
4338 } ,
@@ -63,7 +58,19 @@ const config: PlaywrightTestConfig = {
6358 /* Opt out of parallel tests on CI. */
6459 workers : process . env . CI ? 2 : 2 ,
6560 /* Reporter to use. See https://playwright.dev/docs/test-reporters */
66- reporter,
61+ reporter : [
62+ [ 'list' ] ,
63+ [
64+ 'html' ,
65+ {
66+ open : process . env . CI ? 'never' : 'on-failure' ,
67+ outputFolder : resolve (
68+ process . cwd ( ) ,
69+ process . env . IS_DOCKER ? 'playwright-report-docker' : 'playwright-report' ,
70+ ) ,
71+ } ,
72+ ] ,
73+ ] ,
6774 /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
6875 use : {
6976 testIdAttribute : 'data-qa' ,
0 commit comments