Przeglądaj źródła

modify authFile setup

Yuki Takei 2 lat temu
rodzic
commit
55c7c86515

+ 4 - 1
apps/app/playwright.config.ts

@@ -1,7 +1,10 @@
 import fs from 'node:fs';
+import path from 'node:path';
 
 import { defineConfig, devices } from '@playwright/test';
 
+const authFile = path.resolve(__dirname, './playwright/.auth/admin.json');
+
 /**
  * Read environment variables from file.
  * https://github.com/motdotla/dotenv
@@ -46,7 +49,7 @@ export default defineConfig({
     viewport: { width: 1400, height: 1024 },
 
     // Use prepared auth state.
-    storageState: fs.existsSync('playwright/.auth/admin.json') ? 'playwright/.auth/admin.json' : undefined,
+    storageState: fs.existsSync(authFile) ? authFile : undefined,
   },
 
   /* Configure projects for major browsers */

+ 3 - 1
apps/app/playwright/auth.setup.ts

@@ -1,6 +1,8 @@
+import path from 'node:path';
+
 import { test as setup, expect } from '@playwright/test';
 
-const authFile = 'playwright/.auth/admin.json';
+const authFile = path.resolve(__dirname, './.auth/admin.json');
 
 setup('Authenticate as the "admin" user', async({ page }) => {
   // Perform authentication steps. Replace these actions with your own.