Skip to content

Commit d9112ea

Browse files
authored
feat: update test (#241)
* feat: update test * update ci.yml * update ci.yml * update ci.yml * update ci.yml
1 parent 1e655cf commit d9112ea

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,23 @@ jobs:
1010
strategy:
1111
fail-fast: false
1212
matrix:
13-
os: [windows-latest, macos-latest, ubuntu-latest]
13+
os: [windows-latest, macos-latest] # ubuntu-latest fails with playwright electron.launch
1414

1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1717
- name: Setup nodejs
18-
uses: actions/setup-node@v3
18+
uses: actions/setup-node@v4
1919
with:
20-
node-version: '16'
20+
node-version: '20'
2121
- name: Install dependencies
2222
run: npm install
23+
- name: Install Playwright
24+
run: npx playwright install
2325
- name: Run Test
2426
run: npm test
2527
- name: Upload screenshots
26-
uses: actions/upload-artifact@v3
28+
uses: actions/upload-artifact@v4
29+
if: ${{ always() }}
2730
with:
2831
name: screenshots_${{ matrix.os }}
2932
path: screenshot

playwright.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { defineConfig } from "playwright/test";
2+
3+
export default defineConfig({
4+
testDir: "test",
5+
testMatch: "**/?(*.)+(spec|test).[tj]s?(x)",
6+
});

test/test.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,17 @@ test.afterEach(async ({ page }, testInfo) => {
1717

1818
test('launch app', async () => {
1919
const title = await mainWindow.title();
20-
expect(title).toBe('sbe');
20+
expect(title).toBe('sbe - Scrapbox in Electron');
2121
await mainWindow.screenshot({ path: './screenshot/main.png' });
2222

2323
const packaged = await isPackaged();
2424
expect(packaged).toBe(false);
2525

26-
const windows = await electronApp.windows();
27-
expect(windows.length).toBe(2);
28-
console.log(await windows[1].title());
29-
await windows[1].screenshot({ path: './screenshot/child.png' });
30-
});
31-
32-
test('open fav page', async() => {
33-
await mainWindow.click('#inspire > div.v-application--wrap > header > div.v-toolbar__content > header > div > button:nth-child(11)');
34-
await mainWindow.waitForTimeout(2000);
3526
const windows = await electronApp.windows();
3627
expect(windows.length).toBe(3);
37-
await windows[2].screenshot({ path: './screenshot/favs.png' });
28+
expect(await windows[1].title()).toBe('Start page');
29+
await windows[1].screenshot({ path: './screenshot/child1.png' });
30+
await windows[2].screenshot({ path: './screenshot/child2.png' });
3831
});
3932

4033
async function isPackaged () {

0 commit comments

Comments
 (0)