Skip to content

Commit d16ca1b

Browse files
committed
replace assert with playwright expect
1 parent b4f044c commit d16ca1b

File tree

7 files changed

+5
-17
lines changed

7 files changed

+5
-17
lines changed

scripts/pit/its/bookstore.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const { expect } = require('@playwright/test');
21
const { log, args, createPage, closePage, takeScreenshot, waitForServerReady, dismissDevmode } = require('./test-utils');
32

43
(async () => {

scripts/pit/its/click.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const { expect } = require('@playwright/test');
21
const { log, args, createPage, closePage, takeScreenshot, waitForServerReady, dismissDevmode } = require('./test-utils');
32

43
(async () => {

scripts/pit/its/collaboration.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
const { expect } = require('@playwright/test');
22
const { log, args, createPage, closePage, takeScreenshot, waitForServerReady, dismissDevmode } = require('./test-utils');
3-
// When using playwright in lib mode we cannot use expect, thus we use regular asserts
4-
const assert = require('assert');
53

64
(async () => {
75
const arg = args();
@@ -61,10 +59,10 @@ const assert = require('assert');
6159
let expectedAvatarCount = 2+1;
6260

6361
const avatarCount1 = await page1.locator('vaadin-avatar-group > vaadin-avatar').count();
64-
assert(avatarCount1 === expectedAvatarCount, "Expected two users but found: "+(avatarCount1-1));
62+
expect(avatarCount1).toBe(expectedAvatarCount);
6563

6664
const avatarCount2 = await page2.locator('vaadin-avatar-group > vaadin-avatar').count();
67-
assert(avatarCount2 === expectedAvatarCount, "Expected two users but found: "+(avatarCount2-1));
65+
expect(avatarCount2).toBe(expectedAvatarCount);
6866

6967
log('Avatar counts verified successfully');
7068

scripts/pit/its/hello.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const { expect } = require('@playwright/test');
21
const { log, args, createPage, closePage, takeScreenshot, waitForServerReady, dismissDevmode } = require('./test-utils');
32

43
(async () => {

scripts/pit/its/hilla-react-cli.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const { expect } = require('@playwright/test');
21
const { log, args, createPage, closePage, takeScreenshot, waitForServerReady, dismissDevmode } = require('./test-utils');
32

43
(async () => {

scripts/pit/its/initializer.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
const { expect } = require('@playwright/test');
22
const { log, args, createPage, closePage, takeScreenshot, waitForServerReady, dismissDevmode, execCommand, compileAndReload } = require('./test-utils');
3-
// When using playwright in lib mode we cannot use expect, thus we use regular asserts
4-
const assert = require('assert');
53

6-
const { spawn } = require('child_process');
74
const fs = require('fs');
8-
const Net = require('net');
9-
const isWin = /^win/.test(process.platform);
105

116
(async () => {
127
const arg = args();
@@ -25,7 +20,7 @@ const isWin = /^win/.test(process.platform);
2520
if (arg.mode == 'prod') {
2621
log("Skipping creating views for production mode");
2722
const text = page.getByText('Could not navigate');
28-
assert.ok(await text.isVisible());
23+
await expect(text).toBeVisible();
2924
} else {
3025
const linkText = /react/.test(arg.name) ?
3126
'Create a view for coding the UI in TypeScript with Hilla and React' :
@@ -38,7 +33,7 @@ const isWin = /^win/.test(process.platform);
3833
await takeScreenshot(page, __filename, 'view-created');
3934
await waitForServerReady(page, arg.url, { maxRetries: 30, retryInterval: 2000 });
4035
const view = (await execCommand(`find src/main/frontend src/main/java -name '${viewName}'`)).stdout.trim();
41-
assert.ok(fs.existsSync(view));
36+
expect(fs.existsSync(view)).toBeTruthy();
4237

4338
// Compile the application so as spring-devtools watches the changes
4439
await compileAndReload(page, arg.url, { waitTime: 10000 });
@@ -66,7 +61,7 @@ const isWin = /^win/.test(process.platform);
6661
await takeScreenshot(page, __filename, 'view-reloaded-after-compiling');
6762

6863
const text = page.getByText('Welcome');
69-
assert.ok(await text.isVisible());
64+
await expect(text).toBeVisible();
7065

7166
log(`Removing the view ${view}`);
7267
fs.unlinkSync(view);

scripts/pit/its/k8s-demo.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const { expect} = require('@playwright/test');
21
const { args, createPage, closePage, takeScreenshot, waitForServerReady, dismissDevmode} = require('./test-utils');
32

43
(async () => {

0 commit comments

Comments
 (0)