Skip to content

Commit dcb7bdd

Browse files
committed
build: move test files to src/__tests__ in packages
- 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 is a follow-up for 066d525 and 91a37dc.
1 parent edbbe88 commit dcb7bdd

File tree

211 files changed

+152
-148
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

211 files changed

+152
-148
lines changed

.nycrc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
"examples/*/dist"
66
],
77
"exclude": [
8-
"packages/*/dist/test/",
98
"packages/*/dist/__tests__/",
109
"packages/cli/test/",
11-
"examples/*/dist/test/",
10+
"examples/*/dist/__tests__/",
1211
"**/.sandbox/"
1312
],
1413
"extension": [

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"args": [
1414
"--opts",
1515
"${workspaceRoot}/test/mocha.opts",
16-
"packages/*/dist/test/**/*.js",
16+
"packages/*/dist/__tests__/**/*.js",
1717
"-t",
1818
"0"
1919
]

benchmark/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"build": "lb-tsc es2017 --outDir dist",
1717
"clean": "lb-clean dist",
1818
"pretest": "npm run clean && npm run build",
19-
"test": "lb-mocha \"dist/test\"",
19+
"test": "lb-mocha \"dist/__tests__\"",
2020
"prestart": "npm run build",
2121
"benchmark:routing": "node ./dist/src/rest-routing/routing-table",
2222
"start": "node ."

benchmark/test/benchmark.integration.ts renamed to benchmark/src/__tests__/benchmark.integration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import {expect} from '@loopback/testlab';
77
import * as request from 'request-promise-native';
88
import {Benchmark} from '..';
9-
import {Autocannon, EndpointStats} from '../src/autocannon';
9+
import {Autocannon, EndpointStats} from '../autocannon';
1010

1111
const debug = require('debug')('test');
1212

File renamed without changes.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"test:ci": "node packages/build/bin/run-nyc npm run mocha --scripts-prepend-node-path",
5151
"verify:docs": "npm run build:site -- --verify",
5252
"build:site": "./bin/build-docs-site.sh",
53-
"mocha": "node packages/build/bin/run-mocha \"packages/*/dist/test/**/*.js\" \"packages/*/dist/__tests__/**/*.js\" \"examples/*/dist/__tests__/**/*.js\" \"packages/cli/test/**/*.js\" \"packages/build/test/*/*.js\"",
53+
"mocha": "node packages/build/bin/run-mocha \"packages/*/dist/__tests__/**/*.js\" \"examples/*/dist/__tests__/**/*.js\" \"packages/cli/test/**/*.js\" \"packages/build/test/*/*.js\"",
5454
"posttest": "npm run lint"
5555
},
5656
"config": {

packages/authentication/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
"node": ">=8.9"
77
},
88
"scripts": {
9-
"acceptance": "lb-mocha \"dist/test/acceptance/**/*.js\"",
9+
"acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"",
1010
"build:apidocs": "lb-apidocs",
1111
"build": "lb-tsc es2017 --outDir dist",
1212
"clean": "lb-clean loopback-authentication*.tgz dist package api-docs",
13-
"integration": "lb-mocha \"dist/test/integration/**/*.js\"",
13+
"integration": "lb-mocha \"dist/__tests__/integration/**/*.js\"",
1414
"pretest": "npm run build",
15-
"test": "lb-mocha \"dist/test/unit/**/*.js\" \"dist/test/integration/**/*.js\" \"dist/test/acceptance/**/*.js\"",
16-
"unit": "lb-mocha \"dist/test/unit/**/*.js\"",
15+
"test": "lb-mocha \"dist/__tests__/unit/**/*.js\" \"dist/__tests__/integration/**/*.js\" \"dist/__tests__/acceptance/**/*.js\"",
16+
"unit": "lb-mocha \"dist/__tests__/unit/**/*.js\"",
1717
"verify": "npm pack && tar xf loopback-authentication*.tgz && tree package && npm run clean"
1818
},
1919
"author": "IBM",
@@ -46,9 +46,9 @@
4646
"README.md",
4747
"index.js",
4848
"index.d.ts",
49-
"dist/src",
50-
"dist/index*",
51-
"src"
49+
"dist",
50+
"src",
51+
"!*/__tests__"
5252
],
5353
"repository": {
5454
"type": "git",

packages/authentication/test/unit/providers/auth-metadata.provider.unit.ts renamed to packages/authentication/src/__tests__/unit/providers/auth-metadata.provider.unit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {expect} from '@loopback/testlab';
77
import {CoreBindings} from '@loopback/core';
88
import {Context, Provider} from '@loopback/context';
99
import {AuthenticationMetadata, authenticate} from '../../..';
10-
import {AuthMetadataProvider} from '../../../src/providers';
10+
import {AuthMetadataProvider} from '../../../providers';
1111

1212
describe('AuthMetadataProvider', () => {
1313
let provider: Provider<AuthenticationMetadata | undefined>;

packages/authentication/test/unit/providers/authentication.provider.unit.ts renamed to packages/authentication/src/__tests__/unit/providers/authentication.provider.unit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {Request} from '@loopback/rest';
99
import {AuthenticateFn, UserProfile, AuthenticationBindings} from '../../..';
1010
import {MockStrategy} from '../fixtures/mock-strategy';
1111
import {Strategy} from 'passport';
12-
import {AuthenticateActionProvider} from '../../../src/providers';
12+
import {AuthenticateActionProvider} from '../../../providers';
1313

1414
describe('AuthenticateActionProvider', () => {
1515
describe('constructor()', () => {

packages/authentication/tsconfig.build.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "http://json.schemastore.org/tsconfig",
33
"extends": "@loopback/build/config/tsconfig.common.json",
44
"compilerOptions": {
5-
"rootDir": "."
5+
"rootDir": "src"
66
},
7-
"include": ["index.ts", "src", "test"]
7+
"include": ["src"]
88
}

packages/boot/package.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
"access": "public"
1010
},
1111
"scripts": {
12-
"acceptance": "lb-mocha \"dist/test/acceptance/**/*.js\"",
12+
"acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"",
1313
"build:apidocs": "lb-apidocs",
1414
"build": "lb-tsc es2017 --outDir dist",
1515
"clean": "lb-clean loopback-boot*.tgz dist package api-docs",
1616
"pretest": "npm run build",
17-
"integration": "lb-mocha \"dist/test/integration/**/*.js\"",
18-
"test": "lb-mocha \"dist/test/unit/**/*.js\" \"dist/test/integration/**/*.js\" \"dist/test/acceptance/**/*.js\"",
19-
"unit": "lb-mocha \"dist/test/unit/**/*.js\"",
17+
"integration": "lb-mocha \"dist/__tests__/integration/**/*.js\"",
18+
"test": "lb-mocha \"dist/__tests__/unit/**/*.js\" \"dist/__tests__/integration/**/*.js\" \"dist/__tests__/acceptance/**/*.js\"",
19+
"unit": "lb-mocha \"dist/__tests__/unit/**/*.js\"",
2020
"verify": "npm pack && tar xf loopback-boot*.tgz && tree package && npm run clean"
2121
},
2222
"author": "IBM",
@@ -43,11 +43,10 @@
4343
"files": [
4444
"README.md",
4545
"index.js",
46-
"index.js.map",
4746
"index.d.ts",
48-
"dist/src",
49-
"dist/index*",
50-
"src"
47+
"dist",
48+
"src",
49+
"!*/__tests__"
5150
],
5251
"repository": {
5352
"type": "git",

packages/boot/tsconfig.build.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "http://json.schemastore.org/tsconfig",
33
"extends": "@loopback/build/config/tsconfig.common.json",
44
"compilerOptions": {
5-
"rootDir": "."
5+
"rootDir": "src"
66
},
7-
"include": ["index.ts", "src", "test"]
7+
"include": ["src"]
88
}

packages/build/bin/select-dist.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Then the provided command is executed with the modified arguments.
1818
1919
Example usage:
2020
21-
node ./bin/select-dist mocha dist/test
21+
node ./bin/select-dist mocha dist/__tests__
2222
2323
========
2424
*/

packages/context/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
"node": ">=8.9"
77
},
88
"scripts": {
9-
"acceptance": "lb-mocha \"dist/test/acceptance/**/*.js\"",
9+
"acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"",
1010
"build:apidocs": "lb-apidocs",
1111
"build": "lb-tsc es2017 --outDir dist",
1212
"clean": "lb-clean loopback-context*.tgz dist package api-docs",
1313
"pretest": "npm run build",
14-
"test": "lb-mocha \"dist/test/unit/**/*.js\" \"dist/test/acceptance/**/*.js\"",
15-
"unit": "lb-mocha \"dist/test/unit/**/*.js\"",
14+
"test": "lb-mocha \"dist/__tests__/unit/**/*.js\" \"dist/__tests__/acceptance/**/*.js\"",
15+
"unit": "lb-mocha \"dist/__tests__/unit/**/*.js\"",
1616
"verify": "npm pack && tar xf loopback-context*.tgz && tree package && npm run clean"
1717
},
1818
"author": "IBM",
@@ -46,9 +46,9 @@
4646
"README.md",
4747
"index.js",
4848
"index.d.ts",
49-
"dist/src",
50-
"dist/index*",
51-
"src"
49+
"dist",
50+
"src",
51+
"!*/__tests__"
5252
],
5353
"repository": {
5454
"type": "git",

packages/context/test/acceptance/bind-decorator.acceptance.ts renamed to packages/context/src/__tests__/acceptance/bind-decorator.acceptance.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44
// License text available at https://opensource.org/licenses/MIT
55

66
import {expect} from '@loopback/testlab';
7-
import {Context, bind, BindingScope, Provider} from '../..';
8-
import {createBindingFromClass} from '../../src';
7+
import {
8+
bind,
9+
BindingScope,
10+
Context,
11+
createBindingFromClass,
12+
Provider,
13+
} from '../..';
914

1015
describe('@bind - customize classes with binding attributes', () => {
1116
@bind({

packages/context/test/unit/binding-inspector.unit.ts renamed to packages/context/src/__tests__/unit/binding-inspector.unit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
import {expect} from '@loopback/testlab';
77
import {
88
bind,
9+
BindingFromClassOptions,
910
BindingScope,
1011
BindingScopeAndTags,
1112
Constructor,
1213
Context,
1314
createBindingFromClass,
1415
Provider,
1516
} from '../..';
16-
import {BindingFromClassOptions} from '../../src';
1717

1818
describe('createBindingFromClass()', () => {
1919
it('inspects classes', () => {

packages/context/tsconfig.build.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "http://json.schemastore.org/tsconfig",
33
"extends": "@loopback/build/config/tsconfig.common.json",
44
"compilerOptions": {
5-
"rootDir": "."
5+
"rootDir": "src"
66
},
7-
"include": ["index.ts", "src", "test"]
7+
"include": ["src"]
88
}

packages/core/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
"node": ">=8.9"
77
},
88
"scripts": {
9-
"acceptance": "lb-mocha \"dist/test/acceptance/**/*.js\"",
9+
"acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"",
1010
"build:apidocs": "lb-apidocs",
1111
"build": "lb-tsc es2017 --outDir dist",
1212
"clean": "lb-clean loopback-core*.tgz dist package api-docs",
1313
"pretest": "npm run build",
14-
"integration": "lb-mocha \"dist/test/integration/**/*.js\"",
15-
"test": "lb-mocha \"dist/test/unit/**/*.js\" \"dist/test/integration/**/*.js\" \"dist/test/acceptance/**/*.js\"",
16-
"unit": "lb-mocha \"dist/test/unit/**/*.js\"",
14+
"integration": "lb-mocha \"dist/__tests__/integration/**/*.js\"",
15+
"test": "lb-mocha \"dist/__tests__/unit/**/*.js\" \"dist/__tests__/integration/**/*.js\" \"dist/__tests__/acceptance/**/*.js\"",
16+
"unit": "lb-mocha \"dist/__tests__/unit/**/*.js\"",
1717
"verify": "npm pack && tar xf loopback-core*.tgz && tree package && npm run clean"
1818
},
1919
"author": "IBM",
@@ -32,9 +32,9 @@
3232
"README.md",
3333
"index.js",
3434
"index.d.ts",
35-
"dist/src",
36-
"dist/index*",
37-
"src"
35+
"dist",
36+
"src",
37+
"!*/__tests__"
3838
],
3939
"repository": {
4040
"type": "git",

packages/core/tsconfig.build.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "http://json.schemastore.org/tsconfig",
33
"extends": "@loopback/build/config/tsconfig.common.json",
44
"compilerOptions": {
5-
"rootDir": "."
5+
"rootDir": "src"
66
},
7-
"include": ["index.ts", "src", "test"]
7+
"include": ["src"]
88
}

packages/http-caching-proxy/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"build": "lb-tsc es2017 --outDir dist",
1111
"clean": "lb-clean loopback-caching-proxy*.tgz dist package api-docs",
1212
"pretest": "npm run build",
13-
"test": "lb-mocha \"dist/test/integration/**/*.js\"",
13+
"test": "lb-mocha \"dist/__tests__/integration/**/*.js\"",
1414
"verify": "npm pack && tar xf loopback-caching-proxy*.tgz && tree package && npm run clean"
1515
},
1616
"author": "IBM",
@@ -46,9 +46,9 @@
4646
"README.md",
4747
"index.js",
4848
"index.d.ts",
49-
"dist/src",
50-
"dist/index*",
51-
"src"
49+
"dist",
50+
"src",
51+
"!*/__tests__"
5252
],
5353
"publishConfig": {
5454
"access": "public"

packages/http-caching-proxy/test/integration/http-caching-proxy.integration.ts renamed to packages/http-caching-proxy/src/__tests__/integration/http-caching-proxy.integration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import * as path from 'path';
1212
import * as makeRequest from 'request-promise-native';
1313
import * as rimrafCb from 'rimraf';
1414
import * as util from 'util';
15-
import {HttpCachingProxy, ProxyOptions} from '../../src/http-caching-proxy';
15+
import {HttpCachingProxy, ProxyOptions} from '../../http-caching-proxy';
1616

1717
const CACHE_DIR = path.join(__dirname, '.cache');
1818

packages/http-caching-proxy/test/unit/http-caching-proxy.test.ts renamed to packages/http-caching-proxy/src/__tests__/unit/http-caching-proxy.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// License text available at https://opensource.org/licenses/MIT
55

66
import {expect} from '@loopback/testlab';
7-
import {HttpCachingProxy} from '../../src/http-caching-proxy';
7+
import {HttpCachingProxy} from '../../http-caching-proxy';
88

99
describe('HttpCachingProxy', () => {
1010
describe('constructor', () => {

packages/http-caching-proxy/tsconfig.build.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "http://json.schemastore.org/tsconfig",
33
"extends": "@loopback/build/config/tsconfig.common.json",
44
"compilerOptions": {
5-
"rootDir": "."
5+
"rootDir": "src"
66
},
7-
"include": ["index.ts", "src", "test"]
7+
"include": ["src"]
88
}

packages/http-server/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"build": "lb-tsc es2017 --outDir dist",
1111
"clean": "lb-clean loopback-http-server*.tgz dist package api-docs",
1212
"pretest": "npm run build",
13-
"test": "lb-mocha \"dist/test/**/*.js\"",
13+
"test": "lb-mocha \"dist/__tests__/**/*.js\"",
1414
"verify": "npm pack && tar xf loopback-http-server*.tgz && tree package && npm run clean"
1515
},
1616
"author": "IBM",
@@ -33,9 +33,9 @@
3333
"README.md",
3434
"index.js",
3535
"index.d.ts",
36-
"dist/src",
37-
"dist/index*",
38-
"src"
36+
"dist",
37+
"src",
38+
"!*/__tests__"
3939
],
4040
"publishConfig": {
4141
"access": "public"

packages/http-server/tsconfig.build.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "http://json.schemastore.org/tsconfig",
33
"extends": "@loopback/build/config/tsconfig.common.json",
44
"compilerOptions": {
5-
"rootDir": "."
5+
"rootDir": "src"
66
},
7-
"include": ["index.ts", "src", "test"]
7+
"include": ["src"]
88
}

packages/metadata/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
"node": ">=8.9"
77
},
88
"scripts": {
9-
"acceptance": "lb-mocha \"dist/test/acceptance/**/*.js\"",
9+
"acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"",
1010
"build:apidocs": "lb-apidocs",
1111
"build": "lb-tsc es2017 --outDir dist",
1212
"clean": "lb-clean loopback-metadata*.tgz dist package api-docs",
1313
"pretest": "npm run build",
14-
"test": "lb-mocha \"dist/test/unit/**/*.js\" \"dist/test/acceptance/**/*.js\"",
15-
"unit": "lb-mocha \"dist/test/unit/**/*.js\"",
14+
"test": "lb-mocha \"dist/__tests__/unit/**/*.js\" \"dist/__tests__/acceptance/**/*.js\"",
15+
"unit": "lb-mocha \"dist/__tests__/unit/**/*.js\"",
1616
"verify": "npm pack && tar xf loopback-metadata*.tgz && tree package && npm run clean"
1717
},
1818
"author": "IBM",
@@ -40,9 +40,9 @@
4040
"README.md",
4141
"index.js",
4242
"index.d.ts",
43-
"dist/src",
44-
"dist/index*",
45-
"src"
43+
"dist",
44+
"src",
45+
"!*/__tests__"
4646
],
4747
"publishConfig": {
4848
"access": "public"

packages/metadata/test/unit/reflect.unit.ts renamed to packages/metadata/src/__tests__/unit/reflect.unit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// License text available at https://opensource.org/licenses/MIT
55

66
import {expect} from '@loopback/testlab';
7-
import {NamespacedReflect, Reflector} from '../../src/reflect';
7+
import {NamespacedReflect, Reflector} from '../../reflect';
88
import 'reflect-metadata';
99

1010
function givenReflectContextWithNameSpace(): NamespacedReflect {

0 commit comments

Comments
 (0)