在.gitignore中添加.env文件 添加dotenv依赖管理环境变量 重构测试用例使用环境变量代替硬编码URL 在playwright配置中加载dotenv并设置baseURL
15 lines
364 B
TypeScript
15 lines
364 B
TypeScript
// playwright.config.js
|
|
require('dotenv').config();
|
|
const { defineConfig } = require('@playwright/test');
|
|
|
|
module.exports = defineConfig({
|
|
projects: [
|
|
{
|
|
name: 'chromium',
|
|
use: {
|
|
browserName: 'chromium',
|
|
baseURL: process.env.BASE_URL || 'http://localhost:3000'
|
|
},
|
|
},
|
|
],
|
|
}); |