Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

Commit

Permalink
Added test. Added await to file reading.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jevgenijus Marinuskinas committed Feb 5, 2021
1 parent 5629b64 commit 63706b5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
18 changes: 16 additions & 2 deletions example/tests/elementActions.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Element } from "test-juggler";
const fs = require("fs");
const fs = require("fs").promises;
const fsExtra = require("fs-extra");

describe("Element Actions", () => {
Expand Down Expand Up @@ -353,6 +353,20 @@ describe("Element Actions", () => {
await downloadElement.downloadFile(resultFilePath, true);

//Assert
expect(fs.readFileSync(filePath)).toEqual(fs.readFileSync(resultFilePath));
expect(await fs.readFile(filePath)).toEqual(await fs.readFile(resultFilePath));
});

it("should download a file when an relative path is provided", async () => {
//Arrange
const filePath = process.cwd() + "\\example\\testFiles\\testUpload.json";
const resultFilePath = "\\example\\testFiles\\temp\\testUpload_compare.json";
const downloadElement = new Element("//a[text()='testUpload.json']");
await page.goto("http://the-internet.herokuapp.com/download");

//Act
await downloadElement.downloadFile(resultFilePath, true);

//Assert
expect(await fs.readFile(filePath)).toEqual(await fs.readFile(resultFilePath));
});
});
4 changes: 2 additions & 2 deletions jest-playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ module.exports = {

// Describe which browsers we want to run

browsers: ["chromium", "webkit", "firefox"],
browsers: ["chromium", "webkit"],
exitOnPageError: false,
launchOptions: {

// If we want to run browsers in headless mode or not,

headless: false,
headless: true,

// If we want to have opened devtools from start

Expand Down

0 comments on commit 63706b5

Please sign in to comment.