test: remove split between integration and unit tests, use tags instead

This commit is contained in:
Xymorot 2019-10-10 23:47:13 +02:00
parent 59f2ce6f5f
commit 33c2f9de6f
5 changed files with 14 additions and 8 deletions

View File

@ -1 +1,2 @@
# https://github.com/mochajs/mocha/blob/master/example/config
spec: 'tests/**/*spec.js'

View File

@ -42,6 +42,12 @@ To run migrations:
`node_modules/.bin/typeorm migration:run -c <connection name>`
This is also pre-defined in the npm script `typeorm:migrate`.
## Testing
### Testing
`npm run test`
The testing framework of choice is [Mocha](https://mochajs.org/). Call `npm run test` to run all tests. Tests are written in typescript and need to be transpiled before testing.
#### Tagging
Mocha does [not have a seperate tagging feature](https://github.com/mochajs/mocha/wiki/Tagging), but it can filter via title. Us the following tags in your test titles:
- `@slow` when the test is particularly slow

View File

@ -13,9 +13,8 @@
"typeorm:migrate:library": "typeorm migration:run -c library",
"watch": "gulp build --watch --dev",
"build": "gulp build",
"test:integration": "mocha --spec tests/integration/**/*.spec.js",
"test:unit": "mocha --spec tests/unit/**/*.spec.js",
"test": "mocha --spec tests/**/*.spec.js",
"test:fast": "mocha --grep @slow --invert",
"test": "mocha",
"lint": "npm run eslint && npm run tslint",
"eslint-check": "eslint --print-config gulpfile.js | eslint-config-prettier-check",
"eslint": "eslint .",
@ -26,7 +25,7 @@
"forge:start": "electron-forge start",
"forge:make": "electron-forge --platform win32 --arch x64 make",
"forge": "npm run build && npm run forge:make",
"precommit": "npm run test:unit && npm run prettier:write && npm run eslint-check && npm run tslint-check && npm run lint",
"precommit": "npm run prettier:write && npm run eslint-check && npm run tslint-check && npm run lint && npm run test:fast",
"prepush": "npm run test"
},
"dependencies": {

View File

@ -22,7 +22,7 @@ describe('Application', function(): void {
}
});
it('shows an initial window', function(): any {
it('shows an initial window @slow', function(): any {
return this.app.client.getWindowCount().then((count: number) => {
expect(count).to.be.gte(1);
});

View File

@ -3,7 +3,7 @@ import { afterEach, beforeEach, describe, it } from 'mocha';
import nock from 'nock';
import { Response } from 'node-fetch';
import sinon from 'sinon';
import { fetch } from '../../../../src/main/services/web-crawler';
import { fetch } from '../../../src/main/services/web-crawler';
describe('Web Crawler', function(): void {
this.timeout('2s');