diff --git a/example/tests/elementActions.test.js b/example/tests/elementActions.test.js index 89e5633..21cfabe 100644 --- a/example/tests/elementActions.test.js +++ b/example/tests/elementActions.test.js @@ -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", () => { @@ -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)); }); }); diff --git a/jest-playwright.config.js b/jest-playwright.config.js index fc90cc6..4932409 100644 --- a/jest-playwright.config.js +++ b/jest-playwright.config.js @@ -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