Skip to content

Commit

Permalink
feat(test): add jest config file (#8)
Browse files Browse the repository at this point in the history
* feat(test): add jest config file

* feat(test): add jest config file

* improvement(workflow): update workflow

* improvement(yarn lock): update yarn lock

* improvement: update workflow

* improvement(mock): add mock file

* improvement(workflow): update yarn action

* improvement: update workflow

* improvement: update workflow

* improvement: update workflow
  • Loading branch information
Miaonster authored Dec 17, 2019
1 parent ce0b53a commit e10fd8c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 14 deletions.
32 changes: 18 additions & 14 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@ on: [push]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Run ESLint
uses: stefanoeb/[email protected]
env:
CI: true
- uses: actions/checkout@v1

- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: install
run: yarn

- name: lint
run: yarn lint
2 changes: 2 additions & 0 deletions __mock__/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line import/no-commonjs
module.exports = {}
21 changes: 21 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// eslint-disable-next-line import/no-commonjs
module.exports = {
verbose: true,
moduleFileExtensions: ['js', 'jsx', 'json'],
rootDir: __dirname,
testMatch: [
'<rootDir>/src/components/**/*.test.js',
'<rootDir>/src/components/**/test.js',
],
transform: {
'^.+\\.js?$': 'babel-jest',
},
transformIgnorePatterns: ['<rootDir>/node_modules/'],
moduleNameMapper: {
react: 'nervjs',
'react-addons-test-utils': 'nerv-test-utils',
'react-dom': 'nervjs',
weui: '<rootDir>/__mock__/styleMock.js',
'\\.(css|less|sass|scss)$': '<rootDir>/__mock__/styleMock.js',
},
}

0 comments on commit e10fd8c

Please sign in to comment.