diff --git a/e2e/package.json b/e2e/package.json index 4d288057..1e940733 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -1,6 +1,7 @@ { "name": "towerops-e2e", "version": "1.0.0", + "type": "module", "description": "End-to-end tests for Towerops", "scripts": { "test": "playwright test", @@ -15,6 +16,7 @@ "devDependencies": { "@playwright/test": "^1.48.0", "@types/node": "^22.0.0", + "dotenv": "^17.3.1", "otplib": "^13.0.0" } } diff --git a/e2e/playwright.config.ts b/e2e/playwright.config.ts index 319eabbe..5d086d55 100644 --- a/e2e/playwright.config.ts +++ b/e2e/playwright.config.ts @@ -1,10 +1,11 @@ import { defineConfig, devices } from '@playwright/test'; +import * as dotenv from 'dotenv'; /** * Read environment variables from file. * https://github.com/motdotla/dotenv */ -// require('dotenv').config(); +dotenv.config(); /** * See https://playwright.dev/docs/test-configuration. diff --git a/e2e/tests/auth.setup.ts b/e2e/tests/auth.setup.ts index 4f38bb23..8a591f13 100644 --- a/e2e/tests/auth.setup.ts +++ b/e2e/tests/auth.setup.ts @@ -1,5 +1,5 @@ import { test as setup, expect } from '@playwright/test'; -import { authenticator } from 'otplib'; +import { generateSync } from 'otplib'; const authFile = 'tests/.auth/user.json'; @@ -42,7 +42,7 @@ setup('authenticate', async ({ page }) => { await page.waitForURL('**/users/log_in/totp'); // Generate TOTP code - const token = authenticator.generate(totpSecret); + const token = generateSync({ secret: totpSecret }); console.log(`Generated TOTP token: ${token}`); // Fill in TOTP code diff --git a/e2e/tsconfig.json b/e2e/tsconfig.json index 35ca0bd7..94351719 100644 --- a/e2e/tsconfig.json +++ b/e2e/tsconfig.json @@ -1,14 +1,14 @@ { "compilerOptions": { "target": "ES2020", - "module": "commonjs", + "module": "ESNext", "lib": ["ES2020"], "strict": true, "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true, "resolveJsonModule": true, - "moduleResolution": "node", + "moduleResolution": "bundler", "types": ["node", "@playwright/test"] }, "include": ["tests/**/*.ts"],