jprichardson / electron-mocha

Run Mocha tests in Electron
MIT License
346 stars 64 forks source link

Question: is it possible to run electron-mocha within github actions #208

Closed boly38 closed 8 months ago

boly38 commented 8 months ago

Hi here ✋

I've got a question:

I see in readme a special service for travis but I didnt see github actions notice ?

I notice on my side the following result :

# package.json script definition:
"ci-test": "echo linux ci-test&& export NODE_ENV=githubaction&& c8 --reporter text --reporter=lcov --lines 60 electron-mocha --no-sandbox --trace-warnings --exit --timeout 180000 --unhandled-rejections=strict tests/ci/*.test.js"

# github action stage definition
    - name: Run tests
      run: npm run ci-test
      env:
        # test for electron-mocha
        DISPLAY: :10.0

# github action stage result

Run npm run ci-test
  npm run ci-test
  shell: /usr/bin/bash -e {0}
  env:
    DISPLAY: :10.0

> my-project@0.0.4 ci-test
> echo linux ci-test&& export NODE_ENV=githubaction&& c8 --reporter text --reporter=lcov --lines 60 electron-mocha --no-sandbox --trace-warnings --exit --timeout 180000 --unhandled-rejections=strict tests/ci/*.test.js
linux ci-test
[1787:0[2](REDACTEDjob/21668764014?pr=26#step:5:2)16/194805.[3](REDACTEDjob/21668764014?pr=26#step:5:3)60118:ERROR:ozone_platform_x11.cc(2[4](REDACTEDjob/21668764014?pr=26#step:5:4)0)] Missing X server or $DISPLAY
[1787:0216/19480[5](REDACTEDjob/21668764014?pr=26#step:5:5).3[6](REDACTEDjob/21668764014?pr=26#step:5:6)0165:ERROR:env.cc(25[7](REDACTEDjob/21668764014?pr=26#step:5:8))] The platform failed to initialize.  Exiting.
----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |                   
----------|---------|----------|---------|---------|-------------------
Segmentation fault (core dumped)
Error: Process completed with exit code 13[9](REDACTEDjob/21668764014?pr=26#step:5:10).

I'll try to dig GHactions to see if I find xvfb equivalent, but any help/tips is appreciated

boly38 commented 8 months ago

Ok so few minutes after asking myself I found this actions that fit my need : https://github.com/marketplace/actions/setup-xvfb

As a moderate punishment, I will produce PR 🤣

inukshuk commented 8 months ago

You can also use xvfb-run. For example just do xvfb-run npm test.