Skip to content

Commit

Permalink
Refactor system test code
Browse files Browse the repository at this point in the history
  • Loading branch information
xenosf committed Nov 5, 2024
1 parent 544f54e commit 3297eb3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
9 changes: 5 additions & 4 deletions test/HomePage.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
let {TIMEOUT, getWebDriver, URL} = require("./utils");
let {getWebDriver, ROOT_URL} = require("./utils");
const {By} = require('selenium-webdriver')

let driver;
let url = ROOT_URL;

beforeAll(async () => {
driver = await getWebDriver();
}, TIMEOUT);
}, 10 * 1000);

beforeEach(async () => {
await driver.get(URL);
await driver.get(url);
});

afterAll(async () => {
Expand All @@ -19,6 +20,6 @@ test('clicking "PeerPrep" text in toolbar navigates to homepage', async () => {
let link = await driver.findElement(By.linkText("PeerPrep"));
await link.click();
let newUrl = await driver.getCurrentUrl();
expect(newUrl).toMatch(URL);
expect(newUrl).toMatch(url);
});

3 changes: 1 addition & 2 deletions test/utils.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const { Builder } = require("selenium-webdriver");

module.exports.TIMEOUT = 30 * 1000;

module.exports.URL = "http://localhost:3000";
module.exports.ROOT_URL = "http://localhost:3000";

module.exports.getWebDriver = async () => {
let browser = process.env.BROWSER;
Expand Down

0 comments on commit 3297eb3

Please sign in to comment.