Skip to content

Commit

Permalink
Merge pull request #9 from cowprotocol/2/unit-tests
Browse files Browse the repository at this point in the history
Add missing unit tests
  • Loading branch information
matextrem committed Apr 21, 2022
2 parents 51eeba1 + 776d468 commit d1b9b06
Show file tree
Hide file tree
Showing 10 changed files with 2,737 additions and 2,097 deletions.
19 changes: 12 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Unit tests
on:
pull_request:
push:
branches:
- main
name: Unit tests & Coverage
on: [push, pull_request]

env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

jobs:
test:
Expand Down Expand Up @@ -35,7 +34,7 @@ jobs:
rm -rf .yarncache
yarn cache clean
- name: Run tests
run: 'npm run test'
run: yarn run test:coverage

- name: Comment in failing tests
uses: mattallty/jest-github-action@v1.0.3
Expand All @@ -45,3 +44,9 @@ jobs:
with:
test-command: 'echo unit tests already executed'
coverage-comment: false

- name: Coveralls Report
uses: coverallsapp/github-action@1.1.3
if: success() || failure()
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
node_modules
dist
coverage
.coveralls.yml
jest.results.json
.idea
*.iml
*.iml

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# CoW protocol SDK
[![Styled With Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io/)
[![Coverage Status](https://coveralls.io/repos/github/cowprotocol/cow-sdk/badge.svg?branch=main)](https://coveralls.io/github/cowprotocol/cow-sdk?branch=main)


> ⚠️⚠️ THE SDK IS IN Beta ⚠️⚠️
Expand Down
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"lint": "eslint src",
"format": "prettier --write \"src/**/*.+(ts|json)\"",
"test": "jest",
"test:coverage": "jest --coverage --json --outputFile=jest.results.json && cat ./coverage/lcov.info | coveralls",
"prepare": "npm run build",
"prepublishOnly": "npm test && npm run lint",
"preversion": "npm run lint",
Expand All @@ -36,13 +37,22 @@
"@types/jest": "^27.0.3",
"@typescript-eslint/eslint-plugin": "^5.9.0",
"@typescript-eslint/parser": "^5.9.0",
"coveralls": "^3.1.1",
"eslint": "^8.6.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.3.1",
"jest-fetch-mock": "^3.0.3",
"microbundle": "^0.14.2",
"prettier": "^2.5.1"
},
"jest": {
"automock": false,
"resetMocks": false,
"setupFiles": [
"./setupTests.js"
]
},
"keywords": [
"cow",
"cow-protocol",
Expand Down
11 changes: 11 additions & 0 deletions setupTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import fetchMock from 'jest-fetch-mock'
import log from 'loglevel'

jest.setMock('cross-fetch', fetchMock)

global.window = global

log.info = jest.fn
log.debug = jest.fn
log.error = jest.fn
log.setLevel = jest.fn

0 comments on commit d1b9b06

Please sign in to comment.