Skip to content

Commit

Permalink
Merge pull request #252 from oceanprotocol/feature/testing
Browse files Browse the repository at this point in the history
Test coverage setup
  • Loading branch information
kremalicious authored Sep 7, 2020
2 parents c3381fd + 2f3f5b1 commit 7eb7730
Show file tree
Hide file tree
Showing 9 changed files with 237 additions and 1,652 deletions.
15 changes: 13 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ before_install:
- npm install -g npm

before_script:
# CodeClimate test reporter setup
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
# Barge setup
- git clone https://github.com/oceanprotocol/barge
- cd barge
- git checkout v3
Expand All @@ -27,8 +32,14 @@ before_script:
script:
- npm run lint
- npm run build
- npm run test:cover
- npm run test:integration
- npm run test:unit:cover
- npm run test:integration:cover

after_script:
- ./cc-test-reporter format-coverage -t lcov -o coverage/codeclimate.unit.json coverage/unit/lcov.info # Format unit test coverage
- ./cc-test-reporter format-coverage -t lcov -o coverage/codeclimate.integration.json coverage/integration/lcov.info # Format integration test coverage
- ./cc-test-reporter sum-coverage coverage/codeclimate.*.json -p 2 # Sum both coverage parts into coverage/codeclimate.json
- if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then ./cc-test-reporter upload-coverage; fi # Upload coverage/codeclimate.json

notifications:
email: false
Expand Down
50 changes: 48 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
[![banner](https://raw.githubusercontent.com/oceanprotocol/art/master/github/repo-banner%402x.png)](https://oceanprotocol.com)

<h1 align="center">Ocean-lib</h1>
<h1 align="center">ocean-lib-js</h1>

> JavaScript library to privately & securely publish, exchange, and consume data.
[![npm](https://img.shields.io/npm/v/@oceanprotocol/lib.svg)](https://www.npmjs.com/package/@oceanprotocol/lib)
[![Build Status](https://travis-ci.com/oceanprotocol/ocean-lib-js.svg?token=soMi2nNfCZq19zS1Rx4i&branch=main)](https://travis-ci.com/oceanprotocol/ocean-lib-js)
[![Maintainability](https://api.codeclimate.com/v1/badges/58a59c9029ac615acadc/maintainability)](https://codeclimate.com/repos/5f521329523d1e017600e2ae/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/58a59c9029ac615acadc/test_coverage)](https://codeclimate.com/repos/5f521329523d1e017600e2ae/test_coverage)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-7b1173.svg?style=flat-square)](https://github.com/prettier/prettier)
[![js oceanprotocol](https://img.shields.io/badge/js-oceanprotocol-7b1173.svg)](https://github.com/oceanprotocol/eslint-config-oceanprotocol)

Expand All @@ -19,7 +21,7 @@ With it, you can:
- **Transfer** data tokens to another owner, and **all other ERC20 actions**
using [web3.js](https://web3js.readthedocs.io/en/v1.2.9/web3-eth-contract.html) etc.

`ocean-lib` is part of the [Ocean Protocol](https://oceanprotocol.com) toolset.
`ocean-lib-js` is part of the [Ocean Protocol](https://oceanprotocol.com) toolset.

This is in alpha state and you can expect running into problems. If you run into them, please open up a [new issue](/issues).

Expand All @@ -29,6 +31,9 @@ This is in alpha state and you can expect running into problems. If you run into
- [Marketplace Flow](#marketplace-flow)
- [🦑 Development](#-development)
- [✨ Code Style](#-code-style)
- [👩‍🔬 Testing](#-testing)
- [Unit Tests](#unit-tests)
- [Integration Tests](#integration-tests)
- [🛳 Production](#-production)
- [⬆️ Releases](#️-releases)
- [Production](#production)
Expand Down Expand Up @@ -76,6 +81,47 @@ npm run lint
npm run format
```

## 👩‍🔬 Testing

Test suite for unit & integration tests is setup with [Mocha](https://mochajs.org) as test runner, and [nyc](https://github.com/istanbuljs/nyc) for coverage reporting. A combined coverage report is sent to CodeClimate via Travis.

### Unit Tests

Running unit tests requires running Ganache beforehand:

```bash
npm i -g ganache-cli
ganache-cli
```

After that is running you can execute the unit tests in another terminal:

```bash
npm run test:unit
# same thing, but with coverage reporting
npm run test:unit:coverage
```

### Integration Tests

Running integration tests requires running Ocean Protocol components beforehand with [Barge](https://github.com/oceanprotocol/barge):

```bash
git clone https://github.com/oceanprotocol/barge
cd barge
git checkout v3
export PROVIDER_VERSION=latest
bash -x start_ocean.sh --no-dashboard 2>&1 > start_ocean.log
```

After that is running you can execute the integration tests in another terminal:

```bash
npm run test:integration
# same thing, but with coverage reporting
npm run test:integration:coverage
```

## 🛳 Production

To create a production build, run from the root of the project:
Expand Down
Loading

0 comments on commit 7eb7730

Please sign in to comment.