Skip to content

Commit 5da50f3

Browse files
fix: don't include jest-utils in main package (#15)
1 parent 1ea0b7c commit 5da50f3

14 files changed

+136
-6
lines changed

angular.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,33 @@
9494
}
9595
}
9696
}
97+
},
98+
"jest-utils": {
99+
"root": "projects/jest-utils",
100+
"sourceRoot": "projects/jest-utils/src",
101+
"projectType": "library",
102+
"prefix": "lib",
103+
"architect": {
104+
"build": {
105+
"builder": "@angular-devkit/build-ng-packagr:build",
106+
"options": {
107+
"tsConfig": "projects/jest-utils/tsconfig.lib.json",
108+
"project": "projects/jest-utils/ng-package.json"
109+
},
110+
"configurations": {
111+
"production": {
112+
"project": "projects/jest-utils/ng-package.prod.json"
113+
}
114+
}
115+
},
116+
"lint": {
117+
"builder": "@angular-devkit/build-angular:tslint",
118+
"options": {
119+
"tsConfig": ["projects/jest-utils/tsconfig.lib.json", "./tsconfig.spec.json"],
120+
"exclude": ["**/node_modules/**"]
121+
}
122+
}
123+
}
97124
}
98125
},
99126
"defaultProject": "testing-library-app"

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
"ng": "ng",
66
"start": "ng serve",
77
"prebuild": "rimraf dist",
8-
"build": "npm run build:library && npm run build:migrations && npm run build:readme",
8+
"build": "npm run build:library && npm run build:library:jest-utils && npm run build:migrations && npm run build:readme",
99
"build:library": "ng build --prod testing-library",
10+
"build:library:jest-utils": "ng build --prod jest-utils",
1011
"build:migrations": "tsc -p ./projects/testing-library/migrations/tsconfig.migrations.json && cp ./projects/testing-library/migrations/migration.json ./dist/@angular-extensions/testing-library/migrations",
1112
"build:readme": "cp ./README.md ./dist/@angular-extensions/testing-library",
1213
"test": "jest --config ./projects/jest.lib.config.js",

projects/jest-utils/ng-package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3+
"dest": "../../@angular-extensions/testing-library/jest-utils",
4+
"deleteDestPath": false,
5+
"lib": {
6+
"entryFile": "src/public_api.ts"
7+
}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3+
"dest": "../../dist/@angular-extensions/testing-library/jest-utils",
4+
"deleteDestPath": false,
5+
"lib": {
6+
"entryFile": "src/public_api.ts"
7+
}
8+
}

projects/jest-utils/package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "@angular-extensions/testing-library/jest-utils",
3+
"version": "0.0.0-semantically-released",
4+
"description": "Test your Angular components with the dom-testing-library",
5+
"repository": {
6+
"type": "git",
7+
"url": "git+https://github.com/angular-extensions/testing-library.git"
8+
},
9+
"keywords": [
10+
"angular",
11+
"ngx",
12+
"ng",
13+
"typescript",
14+
"angular2",
15+
"test",
16+
"dom-testing-library",
17+
"angular-extensions"
18+
],
19+
"author": "Tim Deschryver",
20+
"license": "MIT",
21+
"bugs": {
22+
"url": "https://github.com/angular-extensions/testing-library/issues"
23+
},
24+
"homepage": "https://github.com/angular-extensions/testing-library#readme",
25+
"publishConfig": {
26+
"access": "public"
27+
}
28+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { TestBed, getTestBed, ComponentFixture } from '@angular/core/testing';
2+
import 'jest';
3+
4+
// Ref: https://github.com/angular/angular/issues/12409
5+
export function configureJestSetup() {
6+
const testBedApi: any = getTestBed();
7+
const originReset = TestBed.resetTestingModule;
8+
9+
beforeAll(() => {
10+
TestBed.resetTestingModule();
11+
TestBed.resetTestingModule = () => TestBed;
12+
});
13+
14+
afterEach(() => {
15+
testBedApi._activeFixtures.forEach((fixture: ComponentFixture<any>) => fixture.destroy());
16+
testBedApi._instantiated = false;
17+
});
18+
19+
afterAll(() => {
20+
TestBed.resetTestingModule = originReset;
21+
TestBed.resetTestingModule();
22+
});
23+
}

projects/jest-utils/src/lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './configure-test-suite';

projects/jest-utils/src/public_api.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/*
2+
* Public API Surface of testing-library
3+
*/
4+
5+
export * from './lib';

projects/jest-utils/tsconfig.lib.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../out-tsc/lib",
5+
"target": "es2015",
6+
"module": "es2015",
7+
"moduleResolution": "node",
8+
"declaration": true,
9+
"sourceMap": true,
10+
"inlineSources": true,
11+
"emitDecoratorMetadata": true,
12+
"experimentalDecorators": true,
13+
"importHelpers": true,
14+
"types": [],
15+
"lib": ["dom", "es2015"]
16+
},
17+
"angularCompilerOptions": {
18+
"annotateForClosureCompiler": true,
19+
"skipTemplateCodegen": true,
20+
"strictMetadataEmit": true,
21+
"fullTemplateTypeCheck": true,
22+
"strictInjectionParameters": true,
23+
"flatModuleId": "AUTOGENERATED",
24+
"flatModuleOutFile": "AUTOGENERATED"
25+
},
26+
"exclude": ["src/test.ts", "**/*.spec.ts"]
27+
}

projects/jest-utils/tslint.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "../../tslint.json"
3+
}

projects/testing-library/ng-package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3-
"dest": "../../@angular-extensions/testing-library",
3+
"dest": "../../dist/@angular-extensions/testing-library",
44
"deleteDestPath": false,
55
"lib": {
66
"entryFile": "src/public_api.ts"

projects/testing-library/src/lib/testing-library.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { Component, OnInit, ElementRef, Type, DebugElement } from '@angular/core';
2+
import { By } from '@angular/platform-browser';
23
import { TestBed, ComponentFixture } from '@angular/core/testing';
34
import { getQueriesForElement, prettyDOM, fireEvent, FireObject, FireFunction } from 'dom-testing-library';
4-
55
import { RenderResult, RenderOptions } from './models';
6-
import { By } from '@angular/platform-browser';
76

87
@Component({ selector: 'wrapper-component', template: '' })
98
class WrapperComponent implements OnInit {

projects/testing-library/src/public_api.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44

55
export * from './lib/models';
66
export * from './lib/testing-library';
7-
export * from './jest-utils';
87
export * from 'dom-testing-library';

src/app/app.component.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { AppComponent } from './app.component';
2-
import { render, configureJestSetup } from '@angular-extensions/testing-library';
2+
import { render } from '@angular-extensions/testing-library';
3+
import { configureJestSetup } from '@angular-extensions/testing-library/jest-utils';
34

45
configureJestSetup();
56

0 commit comments

Comments
 (0)