Skip to content

Commit 9c9a76a

Browse files
committed
(#246) Added dedicated test to verify builds against Electron
1 parent 2430f6e commit 9c9a76a

File tree

18 files changed

+20263
-24835
lines changed

18 files changed

+20263
-24835
lines changed

.build/build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ echo "Entering working directory $targetDir"
2121
cd $targetDir
2222
echo "Installing node version $nodeVersion"
2323
nvm install $nodeVersion
24-
echo "npm run coverage"
24+
25+
npm ci
2526
E2E_TEST=1 npm run coverage -- --coverageDirectory=coverage/e2e

e2e/tests/lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"packages": [
33
"packages/*"
44
],
5-
"version": "1.4.2"
5+
"version": "1.6.0"
66
}

e2e/tests/package-lock.json

Lines changed: 9207 additions & 22166 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e/tests/package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,10 @@
2222
},
2323
"homepage": "https://github.com/nut-tree/nut.js#readme",
2424
"devDependencies": {
25-
"electron": "13.1.6",
26-
"jest": "26.6.3",
27-
"lerna": "3.22.1",
28-
"spectron": "15.0.0",
29-
"@nut-tree/nut-js": "file:../../"
25+
"lerna": "3.22.1"
3026
},
3127
"dependencies": {
32-
"window-integration-tests": "file:packages/window-integration-tests"
28+
"window-integration-tests": "file:packages/window-integration-tests",
29+
"electron-tests": "file:packages/electron"
3330
}
3431
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# nut.js Electron sample
2+
3+
nut.js is compatible with both node and Electron runtimes.
4+
5+
- [Setup](#setup)
6+
7+
## Setup
8+
9+
Using nut.js with Electron requires compatible OpenCV bindings.
10+
11+
[electron-rebuild](https://www.npmjs.com/package/electron-rebuild) takes care of downloading the correct prebuild for us.
12+
13+
```shell script
14+
npm i -D electron-rebuild
15+
```
16+
17+
In our sample we call `electron-rebuild` in the `pretest` phase, so everything will be set up before we execute our demo.
18+
19+
Running `npm test` will spawn a new Electron application.
20+
21+
nut.js will search for the button displayed in the center of the window and click it, which will exit our application.
22+
23+
In case we're unable to locate the button, our application will run into a timeout and exit with non-zero exitcode.
3.27 KB
Loading
9.75 KB
Loading
3.27 KB
Loading
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
body {
2+
width: 100vw;
3+
height: 100vh;
4+
}
5+
6+
#content {
7+
display: flex;
8+
flex-direction: row;
9+
align-items: center;
10+
justify-content: center;
11+
height: 100vh;
12+
width: 100vw;
13+
}
14+
15+
#exit {
16+
color: white;
17+
font-size: 1.5rem;
18+
background: darkblue;
19+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
6+
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
7+
<link href="index.css" rel="stylesheet"/>
8+
<title>Hello from nut.js!</title>
9+
</head>
10+
<body style="width: 100%; height: 100%">
11+
<div id="content">
12+
<button id="exit">Click me!</button>
13+
</div>
14+
<script src="renderer.js"></script>
15+
</body>
16+
</html>

0 commit comments

Comments
 (0)