Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

test: remove timeout from login test

thecodrre9780306c7d8
diff --git a/apps/web/__e2e__/navigation.test.js b/apps/web/__e2e__/navigation.test.js
index 1e2a1c97d..9689ad64a 100644
--- a/apps/web/__e2e__/navigation.test.js
+++ b/apps/web/__e2e__/navigation.test.js
@@ -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) {
diff --git a/apps/web/__e2e__/user.test.js b/apps/web/__e2e__/user.test.js
index 198aca639..b3755e03b 100644
--- a/apps/web/__e2e__/user.test.js
+++ b/apps/web/__e2e__/user.test.js
@@ -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();
});
diff --git a/apps/web/package.json b/apps/web/package.json
index 86e601ad8..1de6d34dc 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -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",
diff --git a/apps/web/playwright.config.js b/apps/web/playwright.config.js
index 6af8b2fd9..a885a232e 100644
--- a/apps/web/playwright.config.js
+++ b/apps/web/playwright.config.js
@@ -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
diff --git a/apps/web/scripts/run-tests.mjs b/apps/web/scripts/run-tests.mjs
deleted file mode 100644
index 995a66f40..000000000
--- a/apps/web/scripts/run-tests.mjs
+++ /dev/null
@@ -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`;
-}