11// @ts -check
2+ const path = require ( 'path' ) ;
23const { defineConfig, devices } = require ( '@playwright/test' ) ;
3-
44/**
55 * Read environment variables from file.
66 * https://github.com/motdotla/dotenv
77 */
8- // require('dotenv').config({ path: path.resolve(__dirname, '.env') });
8+ require ( 'dotenv' ) . config ( { path : path . resolve ( __dirname , '.env.local' ) } ) ;
9+
10+ // Validate required environment variables
11+ const requiredEnvVars = [ 'REACT_APP_USERNAME' , 'REACT_APP_PASSWORD' ] ;
12+ requiredEnvVars . forEach ( envVar => {
13+ if ( ! process . env [ envVar ] ) {
14+ throw new Error ( `Required environment variable ${ envVar } is missing. Please add it to .env.local` ) ;
15+ }
16+ } ) ;
917
1018/**
1119 * @see https://playwright.dev/docs/test-configuration
1220 */
1321module . exports = defineConfig ( {
14- testDir : './tests ' ,
22+ testDir : './e2eTests ' ,
1523 /* Run tests in files in parallel */
16- fullyParallel : true ,
24+ fullyParallel : false ,
1725 /* Fail the build on CI if you accidentally left test.only in the source code. */
1826 forbidOnly : ! ! process . env . CI ,
1927 /* Retry on CI only */
@@ -22,13 +30,17 @@ module.exports = defineConfig({
2230 workers : process . env . CI ? 1 : undefined ,
2331 /* Reporter to use. See https://playwright.dev/docs/test-reporters */
2432 reporter : 'html' ,
25- /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
2633 use : {
27- /* Base URL to use in actions like `await page.goto('/')`. */
28- // baseURL: 'http://127.0.0.1:3000',
34+ baseURL : 'http://localhost:3000' ,
2935
3036 /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
3137 trace : 'on-first-retry' ,
38+
39+ // Add environment variables to be available in tests
40+ env : {
41+ REACT_APP_USERNAME : process . env . REACT_APP_USERNAME ,
42+ REACT_APP_PASSWORD : process . env . REACT_APP_PASSWORD ,
43+ } ,
3244 } ,
3345
3446 /* Configure projects for major browsers */
@@ -47,33 +59,6 @@ module.exports = defineConfig({
4759 name : 'webkit' ,
4860 use : { ...devices [ 'Desktop Safari' ] } ,
4961 } ,
50-
51- /* Test against mobile viewports. */
52- // {
53- // name: 'Mobile Chrome',
54- // use: { ...devices['Pixel 5'] },
55- // },
56- // {
57- // name: 'Mobile Safari',
58- // use: { ...devices['iPhone 12'] },
59- // },
60-
61- /* Test against branded browsers. */
62- // {
63- // name: 'Microsoft Edge',
64- // use: { ...devices['Desktop Edge'], channel: 'msedge' },
65- // },
66- // {
67- // name: 'Google Chrome',
68- // use: { ...devices['Desktop Chrome'], channel: 'chrome' },
69- // },
7062 ] ,
71-
72- /* Run your local dev server before starting the tests */
73- // webServer: {
74- // command: 'npm run start',
75- // url: 'http://127.0.0.1:3000',
76- // reuseExistingServer: !process.env.CI,
77- // },
7863} ) ;
7964
0 commit comments