Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul the testing system #32

Merged
merged 11 commits into from
May 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ jobs:
- name: Run linting test
run: yarn lint

- name: Run unit tests
run: yarn test

- name: Create a production build
run: yarn build

Expand Down
11 changes: 11 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
roots: [
"<rootDir>"
],
testMatch: [
"**/test/**/*\\.test\\.(ts|tsx|js)",
],
transform: {
"^.+\\.(ts|tsx)$": "ts-jest"
},
}
15 changes: 6 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,20 @@
"build": "tsc",
"lint": "tslint -p tsconfig.json -c tslint.json",
"lint:fix": "tslint --force -p tsconfig.json -c tslint.json",
"test:server:up": "cd .. && PIPENV_DONT_LOAD_ENV=1 pipenv run test-server-up",
"test:server:down": "cd .. && PIPENV_DONT_LOAD_ENV=1 pipenv run test-server-down",
"test:server:clean": "cd .. && PIPENV_DONT_LOAD_ENV=1 pipenv run test-server-clean",
"test:server:restart": "yarn test:server:down; yarn test:server:clean && yarn test:server:up",
"test": "tape -r esm test/**/*.test.js | tap-spec"
"test": "jest"
},
"author": "Kitware, Inc.",
"license": "Apache-2.0",
"dependencies": {
"axios": "^0.19.0"
"axios": "^0.19.0",
"ts-jest": "^26.5.4"
},
"devDependencies": {
"@types/jest": "^26.0.21",
"esm": "^3.2.25",
"tap-spec": "^5.0.0",
"tape": "^4.11.0",
"jest": "^26.6.3",
"tslib": "^1.10.0",
"tslint": "^5.20.0",
"typescript": "^3.6.3"
"typescript": "^4.2.3"
}
}
248 changes: 0 additions & 248 deletions test/multinet.test.js

This file was deleted.

13 changes: 13 additions & 0 deletions test/multinet.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { multinetApi } from '../src/index';
import { AxiosError } from 'axios';

const badApi = multinetApi('http://example.com');

test('bad api', async () => {
expect(badApi).toEqual(expect.anything());

// The "bad api" object should fail when invoked.
await expect(badApi.workspaces())
.rejects
.toHaveProperty('isAxiosError', true);
});
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"sourceMap": true,
"baseUrl": ".",
"types": [
"jest"
],
"paths": {
"@/*": [
Expand All @@ -35,8 +36,8 @@
},
"include": [
"src/**/*.ts",
"tests/**/*.ts",
"tests/**/*.tsx"
"test/**/*.ts",
"test/**/*.tsx"
],
"exclude": [
"node_modules"
Expand Down
Loading