• Stars
    star
    144
  • Rank 255,590 (Top 6 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

❯ ⚛️The easiest way to run and debug test cases in electron with jest.

jest-electron

Easiest way to run jest unit test cases in electron.

When we run unit test in Jest, it is actually running in the node environment, or virtual browser environment(e.g. JSDOM) mocked by NodeJS. Sometimes we need a lot of Jest mocks for running code with no throw, such as: jest-canvas-mock, jest-storage-mock, @jest/fake-timers and so on. This is solved by Jest-Electron.

Build Status npm npm

  1. Technological ecology of Jest.
  2. Complete and real browser environment.
  3. Multi-renderer for running performance.
  4. Running and debug is better then mock.

Installation

  • Add into devDependencies
$ npm i --save-dev jest-electron
  • Update Jest config
{
  "jest": {
+    "runner": "jest-electron/runner",
+    "testEnvironment": "jest-electron/environment"
  }
}

Notice: update the runner configure, not testRunner.

Related

Those will be helpful when run test case with jest-electron.

CI

Run test cases with jest-electron for continuous integration.

  • GitHub action

Running on macOS will be ok.

- runs-on: ubuntu-latest
+ runs-on: macOS-latest
  • travis

Update .travis.yml with electron supported.

language: node_js
node_js:
  - "8"
  - "9"
  - "10"
  - "11"
  - "12"
+ addons:
+   apt:
+     packages:
+       - xvfb
+ install:
+   - export DISPLAY=':99.0'
+   - Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
+   - npm install
script:
  - npm run test

Depending on your executor, you might need to disable sandbox and shared memory usage:

export JEST_ELECTRON_STARTUP_ARGS='--disable-dev-shm-usage --no-sandbox'
npm run test

Env

  • debug mode

Keep the electron browser window for debugging, set process env DEBUG_MODE=1.

DEBUG_MODE=1 jest
  • additional startup arguments

Run electron with arbitrary arguments.

JEST_ELECTRON_STARTUP_ARGS='--disable-dev-shm-usage'

Run electron with --no-sandbox, set process env JEST_ELECTRON_STARTUP_ARGS='--no-sandbox'.

JEST_ELECTRON_STARTUP_ARGS='--no-sandbox' jest

License

MIT@hustcc.

More Repositories

1

JS-Sorting-Algorithm

一本关于排序算法的 GitBook 在线书籍 《十大经典排序算法》,多语言实现。
Java
5,126
star
2

timeago.js

🕗 ⌛ timeago.js is a tiny(2.0 kb) library used to format date with `*** time ago` statement.
TypeScript
5,033
star
3

echarts-for-react

⛳️ Apache ECharts components for React wrapper. 一个简单的 Apache echarts 的 React 封装。
TypeScript
4,485
star
4

canvas-nest.js

♋ Interactive Particle / Nest System With JavaScript and Canvas, no jQuery.
JavaScript
4,278
star
5

PyG2Plot

🎨 Python3 binding for `@AntV/G2Plot` Plotting Library .
Python
1,012
star
6

PTHospital.chrome

⚠️ 🏥 Chrome浏览器插件——打开莆田系医院网站,发出警告提醒、显示医院信息。
JavaScript
573
star
7

onfire.js

🔫 onfire.js is a nano version (~500b) for event-emitter.
TypeScript
498
star
8

timeago-react

🕗 Simple and efficient react component to format date with `*** time ago` statement. eg: '3 hours ago'.
TypeScript
421
star
9

xmorse

🌞 ~1.5Kb morse code library for all. 一个支持 Unicode 中文摩斯密码编码的 Javascript 库。
TypeScript
312
star
10

jest-canvas-mock

🌗 A module used to mock canvas in Jest.
JavaScript
300
star
11

gantt-for-react

🌿 Frappe Gantt components for React wrapper. 一个简单的甘特图 React 组件封装。
JavaScript
291
star
12

react-adsense

📽️ a simple React-component for Google AdSense / Baidu advertisement.
JavaScript
263
star
13

jest-date-mock

🌗 Mock `Date` when run unit test cases with jest. Make tests of Date easier.
JavaScript
259
star
14

timeago

⌛ Simple library used to format datetime with `*** time ago` statement. eg: "3 hours ago".
Python
223
star
15

ribbon.js

🎀 Only 1kb javascript gist to generate a ribbon in your website with HTML5 canvas.
JavaScript
219
star
16

webhookit

:octocat: Simple git webhook cli tool for automation tasks, bind git webhook to action.
Python
192
star
17

alimask

😷 alimask 是一个使用 canvas 生成类似阿里巴巴内部网站水印图片的 JavaScript 库。
JavaScript
176
star
18

size-sensor

🌿 1Kb DOM element size sensor which will callback when size changed.
JavaScript
165
star
19

placeholder.js

⚡ < 1Kb library to generate image placeholders on client side
PHP
161
star
20

chrome-qrcode

⚡ A Chrome plugin to Genrate QRCode of URL / Text, or Decode the QRcode in website. 一个Chrome浏览器插件,用于生成当前URL或者选中内容的二维码,同时可以用于解析网页上的二维码内容。
JavaScript
133
star
21

iReact

🎁 iReact: Fantastic React Components and Libraries! Makes it easy for you to pick one that’ll work for you.
JavaScript
82
star
22

mac.py

⚡A python lib to search Manufacturer of physical network card by mac address. 一个通过物理地址查询网卡所属厂商的Python库。
Python
68
star
23

pixi-action

🏇 pixi-action is a plugin for Pixi.js to create actions and animations easily, inspired by Cocos2d-x.
HTML
65
star
24

word-table

◼️ a simple javascript (browserjs / nodejs) library for drawing tables in the terminal / console, unicode supported.
JavaScript
60
star
25

wrapcache

⚡ A python Function / Method OUTPUT cache system base on function Decorators.
Python
58
star
26

simple-shields

🔰 a simple Shields Badge service with PHP & SVG, Simple, Fast, Stable and Easy Deploy.
HTML
50
star
27

GitHub-Helper.Chrome

:octocat: A Chrome plugin for GitHub Helper. Get a better idea about GitHub.
CSS
40
star
28

GitHub-Repo-Widget.js

:octocat: A good looking github repository widget to add to your website. Not depends on jQuery or Other.
JavaScript
39
star
29

aliyun-oss-deploy

🙈 一个 nodejs 命令行工具,用于部署静态资源到 aliyun oss,支持代码方式和 CLI 方式!
JavaScript
35
star
30

slice.js

🌌 nano library to enhance String.substring / Array.slice with python slice style by Proxy.
JavaScript
34
star
31

hint

重构到 ---> https://github.com/hustcc/lint-md
Python
34
star
32

G2Plot-QRCode

Draw a QRCode with G2Plot.
TypeScript
33
star
33

tplv

👣 Nano string template library for modern, based on ES6 template string syntax.
TypeScript
33
star
34

post-messenger

👶 ~1 Kb wrapper of window.postMessage for cross-document communication.
JavaScript
28
star
35

filesize.js

🔥 filesize.js is a simple(~360 b) module to make file size human-readable.
TypeScript
26
star
36

variable-type

👏 ~ 1 kb. Schema validation. 一个只有 1 kb 的用于变量结构校验的库。
TypeScript
24
star
37

hrn

🔢 Type module to format number into Human-Readable-String. e.g. 4567 -> 4.6 k.
JavaScript
23
star
38

miz

🎯 Generate fake data, Just like a person.
TypeScript
22
star
39

React-G2Plot

🤖 Unofficial react component wrapper for @antvis/G2Plot
TypeScript
21
star
40

return-top

Pure javascript achieve click image to return top of website with animation
JavaScript
19
star
41

xhr.js

🌎 xhr.js is a library(< 2Kb) to make AJAX/HTTP requests with XMLHttpRequest.
JavaScript
19
star
42

jchatting

Chat system developed by Java Swing & Java Socket. 使用Java Swing和Java Socket API实现的聊天系统。
Java
18
star
43

warpart

使用 Flask 做的一个唐诗展示网站。
Python
18
star
44

G2-50-Questions

❓ 500 Questions about G2.
16
star
45

diff-text

Just get the diff of a simple inline text, simple mode.
JavaScript
14
star
46

PrimeTable

Primes Table which Less then Ten million (10000000) 一千万以内的素数表(质数表)。
JavaScript
13
star
47

ding-robot

🤖 钉钉机器人 SDK for Node.js。
JavaScript
13
star
48

babel-plugin-optimize-i18n

🔑 优化国际化文案的 Babel 插件,可以减少国际化文案 40% ~ 50% 的 bundle size。
JavaScript
13
star
49

bmt

📏 in Browser, Measure Text width.
TypeScript
12
star
50

limit-size

🌤️ Lightweight, Convenient, Fast command tool to control your file size by CI, size-limit is too bloated.
TypeScript
11
star
51

uri-parse

🔗 Mini data-uri parser for nodejs and browser. No dependencies!
JavaScript
11
star
52

KeyHelper

😭 好怀念^_^ 基于 Java Swing 的一款键盘改键程序,初衷是用于 Dota 物品和英雄技能改键。
Java
11
star
53

horse.js

🐴 < 3Kb. autocomplete component of pure javascript. 纯Javascript实现的轻量简洁的提示组件。
JavaScript
11
star
54

g2-for-react

📈g2 在 React 上的简单组件包装。React component wrapper of @antvis g2.
JavaScript
11
star
55

clz

✍️ Serverless & Beautiful third-part comment system base on lean cloud.
TypeScript
11
star
56

yuque-lint

Markdown style lint service for Yuque.com base on webhook.
JavaScript
11
star
57

page-fps

🖼️ Inject fps indicator into your page for web performance.
TypeScript
8
star
58

byte-parser

8️⃣ (130B) Parse byte string to byte number, e.g. 1.2 Kb -> 1228.8, Kb, Mb, Gb, Tb, Pb, Eb, Zb, Yb supported.
TypeScript
7
star
59

immutability-util

🌿 Mutate a copy of data without changing the original source by path string, just like the get/set in lodash. Inspired by immutability-helper and rewrite with ES6.
JavaScript
7
star
60

radix.js

💯 a simple javascript module to convent number to your radix, decimal supported.
JavaScript
6
star
61

npm-robbery

🚩 A command tool to register npm package name conveniently.
JavaScript
6
star
62

evenly

💦 How to divide the gold evenly? No surplus. 怎么均匀并且无遗漏的分配黄金?
JavaScript
6
star
63

TODO

📝 A simple github authorized application for server multi-user TODO list.
JavaScript
6
star
64

react-testing-demo

🏁 Ensure code quality of React components with jest, enzyme, jsdom, eslint.
JavaScript
5
star
65

jest-less-loader

⚛️ Jest transformer for .less file.
TypeScript
5
star
66

anyplot

🟪 Web Components for Visualization based on G2.
TypeScript
5
star
67

babel-plugin-version

🏷️ babel plugin replace define identifier `__VERSION__` to pkg.version!
JavaScript
5
star
68

rc-size-sensor

React component wrapper for DOM element size sensor.
TypeScript
4
star
69

charts-perf

Performance tests for charts library.
TypeScript
4
star
70

short-unique-string

🆎 Generate short unique id string locally, used optimize javascript code.
JavaScript
3
star
71

hustcc.github.io

Code for my GitHub profile.
HTML
3
star
72

chart-entanglement

模仿量子特效纠缠实现图表之间的联动。
JavaScript
3
star
73

what.js

👻 only 0.25 kb. what.js is a simple library to get the type of variables. enganced typeof function.
JavaScript
3
star
74

jest-url-loader

⚛️ Similar with webpack's url-loader for Jest.
TypeScript
3
star
75

browser-support-badge

Generate browser version compatibility badges
JavaScript
3
star
76

emoticon.js

{︶。︶}┛ simple javascript library to generate random text emoticon.
JavaScript
3
star
77

hustcc

2
star
78

the-git-commit

:octocat: Nano nodejs module to get information of any git commit.
JavaScript
2
star
79

inject-version

Inject version into your source code when prepublishOnly.
TypeScript
2
star
80

string-shorten

Shorten a string with crc32 and radix.
JavaScript
2
star
81

jest-expect

🃏😂 Make jest expect more convenient.
JavaScript
2
star
82

template

Repository template for @hustcc
JavaScript
1
star
83

pypi-demo

Just a simple pypi package code structure. You can use it to register pypi package name.
Python
1
star
84

gallery

Donate page.
CSS
1
star