Commit 15783134 authored by Rayron Victor's avatar Rayron Victor Committed by 陈帅

fix e2e tests when `PORT` is set in `.env` (#2634)

* SelectLang: languages options don't need to be translated

* fix e2e tests when `PORT` is set in `.env`
parent 8b743adb
import puppeteer from 'puppeteer';
const BASE_URL = `http://localhost:${process.env.PORT || 8000}`;
describe('Homepage', () => {
it('it should have logo text', async () => {
const browser = await puppeteer.launch({ args: ['--no-sandbox'] });
const page = await browser.newPage();
await page.goto('http://localhost:8000', { waitUntil: 'networkidle2' });
await page.goto(BASE_URL, { waitUntil: 'networkidle2' });
await page.waitForSelector('#logo h1');
const text = await page.evaluate(() => document.body.innerHTML);
expect(text).toContain('<h1>Ant Design Pro</h1>');
......
import puppeteer from 'puppeteer';
import RouterConfig from '../../config/router.config';
const BASE_URL = `http://localhost:${process.env.PORT || 8000}`;
function formatter(data) {
return data
.reduce((pre, item) => {
......@@ -22,7 +24,7 @@ describe('Homepage', () => {
const loadPage = async index => {
const path = layout[index];
try {
await page.goto(`http://localhost:8000${path}`, { waitUntil: 'networkidle2' });
await page.goto(`${BASE_URL}${path}`, { waitUntil: 'networkidle2' });
const haveFooter = await page.evaluate(
() => document.getElementsByTagName('footer').length > 0
);
......
import puppeteer from 'puppeteer';
const BASE_URL = `http://localhost:${process.env.PORT || 8000}`;
describe('Login', () => {
let browser;
let page;
......@@ -10,7 +12,7 @@ describe('Login', () => {
beforeEach(async () => {
page = await browser.newPage();
await page.goto('http://localhost:8000/user/login', { waitUntil: 'networkidle2' });
await page.goto(`${BASE_URL}/user/login`, { waitUntil: 'networkidle2' });
await page.evaluate(() => window.localStorage.setItem('antd-pro-authority', 'guest'));
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment