Skip to content

Commit

Permalink
test: init playwright tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY committed Dec 29, 2023
1 parent ce12c83 commit 509fba4
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"build": "lerna run --stream build",
"build:main": "lerna run build --scope=neuron-wallet",
"release": "yarn build && ./scripts/copy-ui-files.sh && ./scripts/release.sh",
"package:e2e": "yarn build && ./scripts/copy-ui-files.sh && npx ncp ./packages/neuron-wallet/dist/ ./packages/e2e/dist",
"package:test": "yarn build && ./scripts/copy-ui-files.sh && ./scripts/package-for-test.sh",
"test": "cross-env NODE_OPTIONS=--openssl-legacy-provider lerna run --parallel --load-env-files=false test",
"test:ci": "yarn build:main && yarn test",
Expand Down
11 changes: 11 additions & 0 deletions packages/e2e/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# `e2e`

> E2E tests of Neuron
## Usage

```
const e2e = require('e2e');
// TODO: DEMONSTRATE API
```
21 changes: 21 additions & 0 deletions packages/e2e/__tests__/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { _electron as electron } from 'playwright'
import { test } from '@playwright/test'

test('Launch Neuron', async () => {
const electronApp = await electron.launch({ args: ['./dist/main.js'] })
const isPackaged = await electronApp.evaluate(async ({ app }) => {
// This runs in Electron's main process, parameter here is always
// the result of the require('electron') in the main app script.
return app.isPackaged
})

expect(isPackaged).toBe(false)

// Wait for the first BrowserWindow to open
// and return its Page object
const window = await electronApp.firstWindow()
await window.screenshot({ path: 'intro.png' })

// close app
await electronApp.close()
})
25 changes: 25 additions & 0 deletions packages/e2e/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "@nervosnetwork/neuron-e2e",
"version": "0.112.0",
"description": "E2E tests of Neuron",
"author": "Keith <[email protected]>",
"homepage": "https://github.com/nervosnetwork/neuron#readme",
"license": "MIT",
"main": "index.js",
"private": true,
"repository": {
"type": "git",
"url": "git+https://github.com/nervosnetwork/neuron.git"
},
"scripts": {
"build:e2e": "cd .. && yarn package:e2e",
"test:e2e": "npx cross-env NODE_ENV=test npx playwright test"
},
"bugs": {
"url": "https://github.com/nervosnetwork/neuron/issues"
},
"devDependencies": {
"@playwright/test": "1.40.1",
"playwright": "1.40.1"
}
}
23 changes: 22 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3841,6 +3841,13 @@
resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33"
integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==

"@playwright/[email protected]":
version "1.40.1"
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.40.1.tgz#9e66322d97b1d74b9f8718bacab15080f24cde65"
integrity sha512-EaaawMTOeEItCRvfmkI9v6rBkF1svM8wjl/YPRrg2N2Wmp+4qJYkWtJsbew1szfKKDm6fPLy4YAanBhIlf9dWw==
dependencies:
playwright "1.40.1"

"@pmmmwh/react-refresh-webpack-plugin@^0.5.1", "@pmmmwh/react-refresh-webpack-plugin@^0.5.3":
version "0.5.10"
resolved "https://registry.yarnpkg.com/@pmmmwh/react-refresh-webpack-plugin/-/react-refresh-webpack-plugin-0.5.10.tgz#2eba163b8e7dbabb4ce3609ab5e32ab63dda3ef8"
Expand Down Expand Up @@ -11235,7 +11242,7 @@ fs.realpath@^1.0.0:
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==

fsevents@^2.1.2, fsevents@^2.3.2, fsevents@~2.3.2:
fsevents@2.3.2, fsevents@^2.1.2, fsevents@^2.3.2, fsevents@~2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
Expand Down Expand Up @@ -16153,6 +16160,20 @@ pkg-up@^3.1.0:
dependencies:
find-up "^3.0.0"

[email protected]:
version "1.40.1"
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.40.1.tgz#442d15e86866a87d90d07af528e0afabe4c75c05"
integrity sha512-+hkOycxPiV534c4HhpfX6yrlawqVUzITRKwHAmYfmsVreltEl6fAZJ3DPfLMOODw0H3s1Itd6MDCWmP1fl/QvQ==

[email protected]:
version "1.40.1"
resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.40.1.tgz#a11bf8dca15be5a194851dbbf3df235b9f53d7ae"
integrity sha512-2eHI7IioIpQ0bS1Ovg/HszsN/XKNwEG1kbzSDDmADpclKc7CyqkHw7Mg2JCz/bbCxg25QUPcjksoMW7JcIFQmw==
dependencies:
playwright-core "1.40.1"
optionalDependencies:
fsevents "2.3.2"

plist@^3.0.4:
version "3.0.6"
resolved "https://registry.yarnpkg.com/plist/-/plist-3.0.6.tgz#7cfb68a856a7834bca6dbfe3218eb9c7740145d3"
Expand Down

1 comment on commit 509fba4

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Packaging for test is done in 7354781442

Please sign in to comment.