|
@@ -1,24 +1,15 @@
|
|
|
-import puppeteer from 'puppeteer';
|
|
|
|
|
-
|
|
|
|
|
const BASE_URL = `http://localhost:${process.env.PORT || 8000}`;
|
|
const BASE_URL = `http://localhost:${process.env.PORT || 8000}`;
|
|
|
|
|
|
|
|
describe('Login', () => {
|
|
describe('Login', () => {
|
|
|
- let browser;
|
|
|
|
|
- let page;
|
|
|
|
|
-
|
|
|
|
|
beforeAll(async () => {
|
|
beforeAll(async () => {
|
|
|
jest.setTimeout(1000000);
|
|
jest.setTimeout(1000000);
|
|
|
- browser = await puppeteer.launch({ args: ['--no-sandbox'] });
|
|
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
beforeEach(async () => {
|
|
|
- page = await browser.newPage();
|
|
|
|
|
await page.goto(`${BASE_URL}/user/login`, { waitUntil: 'networkidle2' });
|
|
await page.goto(`${BASE_URL}/user/login`, { waitUntil: 'networkidle2' });
|
|
|
await page.evaluate(() => window.localStorage.setItem('antd-pro-authority', 'guest'));
|
|
await page.evaluate(() => window.localStorage.setItem('antd-pro-authority', 'guest'));
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- afterEach(() => page.close());
|
|
|
|
|
-
|
|
|
|
|
it('should login with failure', async () => {
|
|
it('should login with failure', async () => {
|
|
|
await page.waitForSelector('#userName', {
|
|
await page.waitForSelector('#userName', {
|
|
|
timeout: 2000,
|
|
timeout: 2000,
|
|
@@ -40,6 +31,4 @@ describe('Login', () => {
|
|
|
const text = await page.evaluate(() => document.body.innerHTML);
|
|
const text = await page.evaluate(() => document.body.innerHTML);
|
|
|
expect(text).toContain('<h1>Ant Design Pro</h1>');
|
|
expect(text).toContain('<h1>Ant Design Pro</h1>');
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
- afterAll(() => browser.close());
|
|
|
|
|
});
|
|
});
|