Skip to content

Commit

Permalink
build(testlab): move test files to src/__tests__
Browse files Browse the repository at this point in the history
This change greatly simplifies our build and project setup.

- Source files are compiled from `src/{foo}` to `dist/{foo}`, the same
  pattern is applied to test files too.

- Both TypeScript sources and JavaScript output are stored in the same
  path relative to project root. This makes it much easier to refer
  to test fixtures.

This change is also enabling future improvements, for example TypeScript
project references and migration to jest test runner.
  • Loading branch information
bajtos committed Jan 31, 2019
1 parent a4c2086 commit 066d525
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions .nycrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
],
"exclude": [
"packages/*/dist/test/",
"packages/*/dist/__tests__/",
"packages/cli/test/",
"examples/*/dist/test/",
"**/.sandbox/"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"test:ci": "node packages/build/bin/run-nyc npm run mocha --scripts-prepend-node-path",
"verify:docs": "npm run build:site -- --verify",
"build:site": "./bin/build-docs-site.sh",
"mocha": "node packages/build/bin/run-mocha \"packages/*/dist/test/**/*.js\" \"examples/*/dist/test/**/*.js\" \"packages/cli/test/**/*.js\" \"packages/build/test/*/*.js\"",
"mocha": "node packages/build/bin/run-mocha \"packages/*/dist/test/**/*.js\" \"packages/*/dist/__tests__/**/*.js\" \"examples/*/dist/test/**/*.js\" \"packages/cli/test/**/*.js\" \"packages/build/test/*/*.js\"",
"posttest": "npm run lint"
},
"config": {
Expand Down
8 changes: 4 additions & 4 deletions packages/testlab/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build:apidocs": "lb-apidocs",
"clean": "lb-clean loopback-testlab*.tgz dist package api-docs",
"pretest": "npm run build",
"test": "lb-mocha \"dist/test\"",
"test": "lb-mocha \"dist/__tests__\"",
"verify": "npm pack && tar xf loopback-testlab*.tgz && tree package && npm run clean"
},
"author": "IBM",
Expand Down Expand Up @@ -39,10 +39,10 @@
"README.md",
"index.js",
"index.d.ts",
"dist/src",
"dist/index*",
"dist",
"should-as-function.d.ts",
"src"
"src",
"!*/__tests__"
],
"repository": {
"type": "git",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {expect} from '../../src/expect';
import {toJSON} from '../../src/to-json';
import {expect} from '../../expect';
import {toJSON} from '../../to-json';

describe('toJSON', () => {
it('removes properties set to undefined', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/testlab/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json.schemastore.org/tsconfig",
"extends": "@loopback/build/config/tsconfig.common.json",
"compilerOptions": {
"rootDir": "."
"rootDir": "src"
},
"include": ["index.ts", "src", "test"]
"include": ["src"]
}

0 comments on commit 066d525

Please sign in to comment.