Lisk-sdk: Run mocha tests by npm scripts & Remove Gruntfile.js

Created on 22 Feb 2019  路  2Comments  路  Source: LiskHQ/lisk-sdk

Rationale

With https://github.com/LiskHQ/lisk/pull/2934, we are introducing jest to our codebase. Running jest as a grunt task creates unintended output and suppresses jest's output colorisation.

That's why the best way to execute test runners is to just use npm scripts. We are going to use npm scripts to run jest tests. In order to align with that, we need to update the way we are running mocha tests.

This will also give developers more flexibility to run tests.

Expected behavior

General command structure will look like this.

npm run mocha:<testType> -- [filepath] [mocha-options]

Where testType can be;

Running existing test suites

The commands will change as below

# Running network tests
npm run mocha:network
npm run mocha:network -- --grep @p2p
npm run mocha:network -- --grep @propagation

# Running unit tests
npm run mocha:unit
npm run mocha:unit -- --grep @slow
npm run mocha:unit -- --grep @unstable
npm run mocha:unit -- --grep @sequential
### extensive
npm run mocha:unit -- --grep="@unstable|@sequential" --invert

# Running Integration tests
npm run mocha:integration -- --grep @slow
npm run mocha:integration -- --grep @unstable
npm run mocha:integration -- --grep @sequential
# extensive
npm run mocha:integration -- --grep="@unstable|@sequential" --invert

# Running functional tests
npm run mocha:functional:ws
npm run mocha:functional:get
npm run mocha:functional:post

Running single file

Running single file can be done by running the command below

npm run mocha:unit -- <filepath> [mocha-options]

Also, using command below still will be possible.

npx mocha <filepath>

Acceptance Criterias

  • [x] Create npm scripts as above
  • [x] Update parallel_tests.js file to support the suggested usage
  • [x] Update Jenkinsfiles
  • [x] Remove Gruntfile.js
  • [x] Update Readme

Actual Behaviour

We are using grunt to execute our test suites at the moment, but this can be simply done by npm scripts.

Steps to reproduce

Which version(s) does this affect? (Environment, OS, etc...)

1.6.0

test framework

Most helpful comment

@yatki looks good to me, I'm glad we're getting rid of the Gruntfile even

All 2 comments

@fchavant Could you please take a look to this issue and let me know if you see any problem with the suggested changes?

@yatki looks good to me, I'm glad we're getting rid of the Gruntfile even

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Isabello picture Isabello  路  4Comments

hendrikhofstadt picture hendrikhofstadt  路  4Comments

karek314 picture karek314  路  3Comments

Nazgolze picture Nazgolze  路  3Comments

ManuGowda picture ManuGowda  路  3Comments