diff --git a/.nycrc b/.nycrc index 736832778af9..b63ce22107ba 100644 --- a/.nycrc +++ b/.nycrc @@ -6,6 +6,7 @@ ], "exclude": [ "packages/*/dist/test/", + "packages/*/dist/__tests__/", "packages/cli/test/", "examples/*/dist/test/", "**/.sandbox/" diff --git a/docs/site/DEVELOPING.md b/docs/site/DEVELOPING.md index 1de5c87348c9..5445b2170970 100644 --- a/docs/site/DEVELOPING.md +++ b/docs/site/DEVELOPING.md @@ -466,7 +466,7 @@ configuration, it's important to verify that all usage scenarios keep working. ### Verify TypeScript setup -1. Open any existing TypeScript file, e.g. `packages/src/index.ts` +1. Open any existing TypeScript file, e.g. `packages/core/src/index.ts` 2. Add a small bit of code to break TypeScript's type checks, for example: @@ -479,10 +479,6 @@ configuration, it's important to verify that all usage scenarios keep working. 4. Verify that the build failed and the compiler error message shows a path relative to monorepo root, e.g. `packages/src/index.ts`. - _(This is does not work now, `tsc` is reporting paths relative to individual - package directories. See - )_ - 5. Test integration with supported IDEs: - [VS Code](./VSCODE.md#how-to-verify-typescript-setup) diff --git a/docs/site/VSCODE.md b/docs/site/VSCODE.md index 79d680c23604..8b3d3d6026e1 100644 --- a/docs/site/VSCODE.md +++ b/docs/site/VSCODE.md @@ -20,7 +20,7 @@ Our monorepo comes with few preconfigured ### Compilation errors -1. Open any existing TypeScript file, e.g. `packages/src/index.ts` +1. Open any existing TypeScript file, e.g. `packages/core/src/index.ts` 2. Add a small bit of code to break TypeScript's type checks, for example: @@ -51,9 +51,7 @@ Our monorepo comes with few preconfigured VSCode. 8. Verify that compilation errors are correctly associated with the problematic - source code line. _(This is does not work now, `tsc` is reporting paths - relative to individual package directories. See - )_ + source code line. ### Navigation in VS Code diff --git a/package.json b/package.json index fe89b0e1020d..4c4515be87ab 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/packages/testlab/fixtures/README.md b/packages/testlab/fixtures/README.md new file mode 100644 index 000000000000..b1296db403b3 --- /dev/null +++ b/packages/testlab/fixtures/README.md @@ -0,0 +1,9 @@ +# Static fixtures + +This directory contains test fixture files that we want to use in verbatim and +also files that TypeScript compiler would not copy from `src` to `dist`. + +For example: + +- text files +- JSON files not imported by any `.ts` file diff --git a/packages/testlab/package.json b/packages/testlab/package.json index 6356b811499c..32a801591f86 100644 --- a/packages/testlab/package.json +++ b/packages/testlab/package.json @@ -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", @@ -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", diff --git a/packages/testlab/src/__tests__/fixtures/README.md b/packages/testlab/src/__tests__/fixtures/README.md new file mode 100644 index 000000000000..d3871836255d --- /dev/null +++ b/packages/testlab/src/__tests__/fixtures/README.md @@ -0,0 +1,4 @@ +# Compiled fixtures + +This directory contains test fixture files that we want to compile by TypeScript +before using in tests. diff --git a/packages/testlab/test/fixtures/test.ts b/packages/testlab/src/__tests__/fixtures/test.ts similarity index 100% rename from packages/testlab/test/fixtures/test.ts rename to packages/testlab/src/__tests__/fixtures/test.ts diff --git a/packages/testlab/test/integration/test-sandbox.integration.ts b/packages/testlab/src/__tests__/integration/test-sandbox.integration.ts similarity index 100% rename from packages/testlab/test/integration/test-sandbox.integration.ts rename to packages/testlab/src/__tests__/integration/test-sandbox.integration.ts diff --git a/packages/testlab/test/integration/testlab.smoke.integration.ts b/packages/testlab/src/__tests__/integration/testlab.smoke.integration.ts similarity index 100% rename from packages/testlab/test/integration/testlab.smoke.integration.ts rename to packages/testlab/src/__tests__/integration/testlab.smoke.integration.ts diff --git a/packages/testlab/test/unit/to-json.test.ts b/packages/testlab/src/__tests__/unit/to-json.test.ts similarity index 97% rename from packages/testlab/test/unit/to-json.test.ts rename to packages/testlab/src/__tests__/unit/to-json.test.ts index 726dd0ef6574..6ac0bc8fb028 100644 --- a/packages/testlab/test/unit/to-json.test.ts +++ b/packages/testlab/src/__tests__/unit/to-json.test.ts @@ -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', () => { diff --git a/packages/testlab/tsconfig.build.json b/packages/testlab/tsconfig.build.json index f8bd0f50ef8f..6e15e4be4f6f 100644 --- a/packages/testlab/tsconfig.build.json +++ b/packages/testlab/tsconfig.build.json @@ -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"] }