GithubHelp home page GithubHelp logo

stefanoeb / jest-action Goto Github PK

View Code? Open in Web Editor NEW
95.0 3.0 20.0 17 KB

Wraps and install Jest test runner in a github action.

License: MIT License

Dockerfile 24.64% Shell 75.36%
actions ci jest javascript

jest-action's Introduction

⚠️⚠️⚠️ You don't need this action ⚠️⚠️⚠️

Github Actions have everything that you need to run your jest tests, to do that simply use the run commands like so:

name: CI
on: push
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Install modules
      run: yarn
    - name: Run tests
      run: yarn test

This action executes Jest test runner without any previous action/build step or Docker required.

Prerequisites

Jest

You must have the Jest running locally for the action to execute. More info on the Jest getting started guide

Usage

Add to your main.yml file or create a new file named .github/workflows/test.yml and add:

name: Tests

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - name: Run Jest
      uses: stefanoeb/[email protected]

You can also pass custom args to jest through the with: parameter:

name: Tests

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - name: Run Jest
      uses: stefanoeb/[email protected]
      with:
        jestArgs: path/to/my.test.js

If there is no previous step installing the necessary modules, this action will execute a yarn install or npm install automatically.

License

The Dockerfile and associated scripts and documentation in this project are released under the MIT License.

jest-action's People

Contributors

gfpacheco avatar guix77 avatar hdv2b avatar moshejs avatar stefanoeb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

jest-action's Issues

Error: "Update dependency jest to v26"

Hi!

FAIL ./mock.spec.js
  ● Test suite failed to run

    ReferenceError: it is not defined

      1 | const capitalize = string => (string ? `${string[0].toUpperCase()}${string.slice(1)}` : '')
      2 | 
    > 3 | it('capitalizes', () => expect(capitalize('hoo')).toEqual('Hoo'))
        | ^
      4 | 

      at Object.<anonymous> (mock.spec.js:3:1)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.105 s
Ran all test suites.

↑ Getting this error when renovate attempts to update jest to v26.

Help?

error Couldn't find the binary git

main.yml:


name: Tests

# Controls when the action will run. Triggers the workflow on push or pull request 
# events but only for the master branch
on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]
    
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Run Jest
      uses: stefanoeb/[email protected]

log:

  with:
/usr/bin/docker run --name e87b52a49f9c02c23a45f889d4b47f4d6f2521_ae8242 --label e87b52 --workdir /github/workspace --rm -e INPUT_JESTARGS -e HOME -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e GITHUB_ACTIONS=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/salestribe-app/salestribe-app":"/github/workspace" e87b52:a49f9c02c23a45f889d4b47f4d6f2521  ""
## Your environment is not ready yet. Installing modules...
## Running Jest
error Couldn't find the binary git

Not sure if this is related to your action or something I've setup wrong. Any help would be appreciated.

How I am doing my tests (without a Dockerfile)

Not sure if this will help, but I have a simplified way of doing it (doesn't rely on docker at all)

name: Tests

on: [push]

jobs:
  unittests:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Run Tests
      run: |
        npm install 
        npm test

Upgrade node version

When using this action, the jest tests are failing now in CI after I upgraded to webpacker 5 with error like...
@rails/[email protected]: The engine "node" is incompatible with this module. Expected version ">=10.17.0". Got "10.14.1"

Can you please upgrade the node version in your docker file by changing this: FROM node:10.14.2-alpine

Subdirectory?

Sorry I'm new to github actions, but is it possible to run this action inside a subdirectory like /express or /client ?

Error: "Update dependency jest to v26"

Hi!

FAIL ./mock.spec.js
  ● Test suite failed to run

    ReferenceError: it is not defined

      1 | const capitalize = string => (string ? `${string[0].toUpperCase()}${string.slice(1)}` : '')
      2 | 
    > 3 | it('capitalizes', () => expect(capitalize('hoo')).toEqual('Hoo'))
        | ^
      4 | 

      at Object.<anonymous> (mock.spec.js:3:1)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.105 s
Ran all test suites.

↑ Getting this error when renovate attempts to update jest to v26.

Any hints?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.