From 2a6dc3036630773b4b1b56525b5774ef6405db9f Mon Sep 17 00:00:00 2001 From: TC Date: Sun, 4 Sep 2022 22:23:51 +0200 Subject: [PATCH] Remove test environment --- tests/environment.js | 38 -------------------------------------- tests/index.test.js | 33 ++++++++++++++++++++++----------- 2 files changed, 22 insertions(+), 49 deletions(-) delete mode 100644 tests/environment.js diff --git a/tests/environment.js b/tests/environment.js deleted file mode 100644 index c1677420..00000000 --- a/tests/environment.js +++ /dev/null @@ -1,38 +0,0 @@ -const path = require("path"); - -const NodeEnvironment = require("jest-environment-node"); -const { _electron: electron } = require("playwright"); - -class TestEnvironment extends NodeEnvironment { - constructor(config) { - super(config); - } - - async setup() { - await super.setup(); - - const appPath = path.resolve(__dirname, ".."); - this.global.__APP__ = await electron.launch({ - args: [ - "--no-sandbox", - "--disable-gpu", - "--whitelisted-ips=", - "--disable-dev-shm-usage", - appPath, - ], - }); - } - - async teardown() { - if (this.global.__APP__) { - await this.global.__APP__.close(); - } - await super.teardown(); - } - - runScript(script) { - return super.runScript(script); - } -} - -module.exports = TestEnvironment; diff --git a/tests/index.test.js b/tests/index.test.js index 62ed9040..01c38576 100644 --- a/tests/index.test.js +++ b/tests/index.test.js @@ -1,16 +1,27 @@ -/** - * @jest-environment ./tests/environment - */ +const path = require("path"); -describe("YouTube Music App", () => { - const app = global.__APP__; +const { _electron: electron } = require("playwright"); +const { test, expect } = require("@playwright/test"); - test("With default settings, app is launched and visible", async () => { - const window = await app.firstWindow(); - const title = await window.title(); - expect(title).toEqual("YouTube Music"); +const appPath = path.resolve(__dirname, ".."); - const url = window.url(); - expect(url.startsWith("https://music.youtube.com")).toBe(true); +test("YouTube Music App - With default settings, app is launched and visible", async () => { + const app = await electron.launch({ + args: [ + "--no-sandbox", + "--disable-gpu", + "--whitelisted-ips=", + "--disable-dev-shm-usage", + appPath, + ], }); + + const window = await app.firstWindow(); + const title = await window.title(); + expect(title).toEqual("YouTube Music"); + + const url = window.url(); + expect(url.startsWith("https://music.youtube.com")).toBe(true); + + await app.close(); });