Skip to content

Commit

Permalink
Setup mocha hooks and add to npm run command
Browse files Browse the repository at this point in the history
  • Loading branch information
sugat009 committed Jun 20, 2024
1 parent 61f4032 commit e787b14
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"docker-start-couchdb": "npm run docker-stop-couchdb && docker run -d -p 6984:5984 --rm --name cht-conf-couchdb couchdb:2.3.1 && sh test/scripts/wait_for_response_code.sh 6984 200 CouchDB",
"docker-stop-couchdb": "docker stop cht-conf-couchdb || true",
"test": "npm run eslint && npm run docker-start-couchdb && npm run clean && mkdir -p build/test && cp -r test/data build/test/data && cd build/test && nyc --reporter=html mocha --forbid-only \"../../test/**/*.spec.js\" && cd ../.. && npm run docker-stop-couchdb",
"test-e2e": "npm run eslint && ./test/e2e/test_runner.sh",
"test-e2e": "npm run eslint && mocha --config test/e2e/.mocharc.js",
"semantic-release": "semantic-release"
},
"bin": {
Expand Down
20 changes: 20 additions & 0 deletions test/e2e/.mocharc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const chaiExclude = require('chai-exclude');
const chaiAsPromised = require('chai-as-promised');
const chai = require('chai');
chai.use(chaiAsPromised);
chai.use(chaiExclude);

module.exports = {
allowUncaught: false,
color: true,
checkLeaks: true,
fullTrace: true,
asyncOnly: false,
spec: require('./specs').all,
timeout: 200 * 1000, //API takes a little long to start up
reporter: 'spec',
file: [ 'test/e2e/hooks.js' ],
captureFile: 'test/e2e/results.txt',
exit: true,
recursive: true,
};
15 changes: 15 additions & 0 deletions test/e2e/hooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
before(() => {
console.log('before');

Check warning on line 2 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 10.x

Unexpected console statement

Check warning on line 2 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 10.x

Unexpected console statement

Check warning on line 2 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 20.x

Unexpected console statement

Check warning on line 2 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 16.x

Unexpected console statement

Check warning on line 2 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 14.x

Unexpected console statement

Check warning on line 2 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 16.x

Unexpected console statement

Check warning on line 2 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 12.x

Unexpected console statement

Check warning on line 2 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 8.x

Unexpected console statement

Check warning on line 2 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 20.x

Unexpected console statement

Check warning on line 2 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 8.x

Unexpected console statement

Check warning on line 2 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 14.x

Unexpected console statement

Check warning on line 2 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 18.x

Unexpected console statement

Check warning on line 2 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 18.x

Unexpected console statement

Check warning on line 2 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 12.x

Unexpected console statement
});

after(() => {
console.log('after');

Check warning on line 6 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 10.x

Unexpected console statement

Check warning on line 6 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 10.x

Unexpected console statement

Check warning on line 6 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 20.x

Unexpected console statement

Check warning on line 6 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 16.x

Unexpected console statement

Check warning on line 6 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 14.x

Unexpected console statement

Check warning on line 6 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 16.x

Unexpected console statement

Check warning on line 6 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 12.x

Unexpected console statement

Check warning on line 6 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 8.x

Unexpected console statement

Check warning on line 6 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 20.x

Unexpected console statement

Check warning on line 6 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 8.x

Unexpected console statement

Check warning on line 6 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 14.x

Unexpected console statement

Check warning on line 6 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 18.x

Unexpected console statement

Check warning on line 6 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 18.x

Unexpected console statement

Check warning on line 6 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 12.x

Unexpected console statement
});

beforeEach(() => {
console.log('beforeEach');

Check warning on line 10 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 10.x

Unexpected console statement

Check warning on line 10 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 10.x

Unexpected console statement

Check warning on line 10 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 20.x

Unexpected console statement

Check warning on line 10 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 16.x

Unexpected console statement

Check warning on line 10 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 14.x

Unexpected console statement

Check warning on line 10 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 16.x

Unexpected console statement

Check warning on line 10 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 12.x

Unexpected console statement

Check warning on line 10 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 8.x

Unexpected console statement

Check warning on line 10 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 20.x

Unexpected console statement

Check warning on line 10 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 8.x

Unexpected console statement

Check warning on line 10 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 14.x

Unexpected console statement

Check warning on line 10 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 18.x

Unexpected console statement

Check warning on line 10 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 18.x

Unexpected console statement

Check warning on line 10 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 12.x

Unexpected console statement
});

afterEach(() => {
console.log('afterEach');

Check warning on line 14 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 10.x

Unexpected console statement

Check warning on line 14 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 10.x

Unexpected console statement

Check warning on line 14 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 20.x

Unexpected console statement

Check warning on line 14 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 16.x

Unexpected console statement

Check warning on line 14 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 14.x

Unexpected console statement

Check warning on line 14 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 16.x

Unexpected console statement

Check warning on line 14 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 12.x

Unexpected console statement

Check warning on line 14 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 8.x

Unexpected console statement

Check warning on line 14 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 20.x

Unexpected console statement

Check warning on line 14 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 8.x

Unexpected console statement

Check warning on line 14 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 14.x

Unexpected console statement

Check warning on line 14 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 18.x

Unexpected console statement

Check warning on line 14 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 18.x

Unexpected console statement

Check warning on line 14 in test/e2e/hooks.js

View workflow job for this annotation

GitHub Actions / Build for Node version 12.x

Unexpected console statement
});
7 changes: 7 additions & 0 deletions test/e2e/placeholder.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const assert = require('assert');

describe('placeholder', () => {
it('checks if the mocha test setup works', () => {
assert.strictEqual(1, 1);
});
});
5 changes: 5 additions & 0 deletions test/e2e/specs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
all: [
'test/e2e/**/*.spec.js'
]
};

0 comments on commit e787b14

Please sign in to comment.