test: remove timeout from login test

This commit is contained in:
thecodrr
2021-09-13 11:08:28 +05:00
parent 92537acca9
commit e9780306c7
5 changed files with 18 additions and 49 deletions

View File

@@ -3,8 +3,8 @@
const { test, expect } = require("@playwright/test");
const { getTestId } = require("./utils");
test.beforeEach(async ({ page }) => {
await page.goto("http://localhost:3000");
test.beforeEach(async ({ page, baseURL }) => {
await page.goto(baseURL);
});
function createRoute(key, header) {

View File

@@ -1,6 +1,6 @@
const { Page, test, expect } = require("@playwright/test");
const { getTestId } = require("./utils");
const { isAbsent } = require("./utils/conditions");
const { isAbsent, isPresent } = require("./utils/conditions");
const dotenv = require("dotenv");
const path = require("path");
@@ -11,10 +11,10 @@ dotenv.config({ path: path.join(__dirname, ".env.local") });
*/
var page = null;
global.page = null;
test.beforeEach(async ({ page: _page }) => {
test.beforeEach(async ({ page: _page, baseURL }) => {
global.page = _page;
page = _page;
await page.goto("http://localhost:3000/");
await page.goto(baseURL);
});
const USER = {
@@ -31,11 +31,13 @@ async function loginUser() {
await page.click(getTestId("submitButton"));
await page.waitForNavigation();
await page.waitForSelector(getTestId("navitem-sync"));
expect(await isAbsent(getTestId("navitem-login"))).toBe(true);
expect(await isPresent(getTestId("navitem-sync"))).toBe(true);
}
test("login user", async () => {
test("login user", async ({}, info) => {
info.setTimeout(0);
await loginUser();
});

View File

@@ -80,7 +80,7 @@
"build:desktop": "env-cmd -e all,desktop react-scripts build",
"deploy": "./scripts/deploy.sh",
"debug": "env-cmd -e all,dev,web,silent react-scripts start",
"test": "yarn zx ./scripts/run-tests.mjs",
"test": "npm exec playwright test",
"test:debug": "env-cmd -e dev,debug,silent jest -c jest.e2e.config.js",
"eject": "react-scripts eject",
"update": "npm i @streetwriters/editor@latest @streetwriters/notesnook-core@latest @streetwriters/theme@latest",

View File

@@ -1,7 +1,13 @@
const IS_CI = !!process.env.CI;
module.exports = {
// Look for test files in the "tests" directory, relative to this configuration file
webServer: {
command: "npm run debug",
port: 3000,
timeout: 120 * 1000,
reuseExistingServer: false, //!IS_CI,
},
// Look for test files in thcleare "tests" directory, relative to this configuration file
testDir: "__e2e__",
// Each test is given 30 seconds

View File

@@ -1,39 +0,0 @@
const find = require("find-process");
const { p, updateSnapshots, file, noServer } = argv;
if (!noServer) {
await killServer();
const res = nothrow($`yarn debug -p ${p || 3000}`);
res.stdout.on("data", async (data) => {
const message = data.toString();
if (
message.includes("create a production build, use yarn build.") ||
message.includes("Compiled with warnings")
) {
const testRes = await startTestRunner();
await killServer();
process.exit(testRes.exitCode);
}
});
} else {
const testRes = await startTestRunner();
process.exit(testRes.exitCode);
}
async function killServer() {
const nodeProcesses = await find("name", "node");
const reactServerProcesses = nodeProcesses.filter((p) =>
p.cmd.includes("react-scripts")
);
for (let rprocess of reactServerProcesses) {
process.kill(rprocess.pid, "SIGINT");
}
}
async function startTestRunner() {
if (!updateSnapshots && !file) return $`yarn playwright test`;
else if (updateSnapshots && file) return $`yarn playwright test -u ${file}`;
else if (file) return $`yarn playwright test ${file}`;
else if (updateSnapshots) return $`yarn playwright test -u`;
}