Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
fix: refactored tests setup
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiejaoude committed Oct 29, 2022
1 parent 99e12a3 commit 4dc16c4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 20 deletions.
4 changes: 2 additions & 2 deletions playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ const config = {
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
},
globalSetup: require.resolve("./tests/global-setup"),
globalTeardown: require.resolve("./tests/global-teardown"),
globalSetup: require.resolve("./tests/setup/global-setup"),
globalTeardown: require.resolve("./tests/setup/global-teardown"),
};

module.exports = config;
11 changes: 0 additions & 11 deletions tests/global-teardown.js

This file was deleted.

10 changes: 3 additions & 7 deletions tests/global-setup.js → tests/setup/global-setup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const { chromium } = require("@playwright/test");
const fs = require("fs");

const { USERS } = require("./test-users.js");

const user = (username) => {
return {
name: username.toUpperCase(),
Expand All @@ -24,13 +26,7 @@ const user = (username) => {
};

module.exports = async (config) => {
const users = [
"_test-profile-user-1",
"_test-profile-user-2",
"_test-profile-user-3",
];

users.forEach((username) => {
USERS.forEach((username) => {
const data = user(username);

try {
Expand Down
8 changes: 8 additions & 0 deletions tests/setup/global-teardown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const { chromium } = require("@playwright/test");
const fs = require("fs");

const { USERS } = require("./test-users.js");

module.exports = async (config) => {
USERS.forEach((username) => fs.unlinkSync(`./data/${username}.json`));
};
5 changes: 5 additions & 0 deletions tests/setup/test-users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const USERS = [
"_test-profile-user-1",
"_test-profile-user-2",
"_test-profile-user-3",
];

0 comments on commit 4dc16c4

Please sign in to comment.