Skip to content

Commit

Permalink
fix: don't include jest-utils in main package (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
timdeschryver authored May 13, 2019
1 parent 1ea0b7c commit 5da50f3
Show file tree
Hide file tree
Showing 14 changed files with 136 additions and 6 deletions.
27 changes: 27 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,33 @@
}
}
}
},
"jest-utils": {
"root": "projects/jest-utils",
"sourceRoot": "projects/jest-utils/src",
"projectType": "library",
"prefix": "lib",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "projects/jest-utils/tsconfig.lib.json",
"project": "projects/jest-utils/ng-package.json"
},
"configurations": {
"production": {
"project": "projects/jest-utils/ng-package.prod.json"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["projects/jest-utils/tsconfig.lib.json", "./tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
}
}
}
}
},
"defaultProject": "testing-library-app"
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"ng": "ng",
"start": "ng serve",
"prebuild": "rimraf dist",
"build": "npm run build:library && npm run build:migrations && npm run build:readme",
"build": "npm run build:library && npm run build:library:jest-utils && npm run build:migrations && npm run build:readme",
"build:library": "ng build --prod testing-library",
"build:library:jest-utils": "ng build --prod jest-utils",
"build:migrations": "tsc -p ./projects/testing-library/migrations/tsconfig.migrations.json && cp ./projects/testing-library/migrations/migration.json ./dist/@angular-extensions/testing-library/migrations",
"build:readme": "cp ./README.md ./dist/@angular-extensions/testing-library",
"test": "jest --config ./projects/jest.lib.config.js",
Expand Down
8 changes: 8 additions & 0 deletions projects/jest-utils/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../@angular-extensions/testing-library/jest-utils",
"deleteDestPath": false,
"lib": {
"entryFile": "src/public_api.ts"
}
}
8 changes: 8 additions & 0 deletions projects/jest-utils/ng-package.prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/@angular-extensions/testing-library/jest-utils",
"deleteDestPath": false,
"lib": {
"entryFile": "src/public_api.ts"
}
}
28 changes: 28 additions & 0 deletions projects/jest-utils/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "@angular-extensions/testing-library/jest-utils",
"version": "0.0.0-semantically-released",
"description": "Test your Angular components with the dom-testing-library",
"repository": {
"type": "git",
"url": "git+https://github.com/angular-extensions/testing-library.git"
},
"keywords": [
"angular",
"ngx",
"ng",
"typescript",
"angular2",
"test",
"dom-testing-library",
"angular-extensions"
],
"author": "Tim Deschryver",
"license": "MIT",
"bugs": {
"url": "https://github.com/angular-extensions/testing-library/issues"
},
"homepage": "https://github.com/angular-extensions/testing-library#readme",
"publishConfig": {
"access": "public"
}
}
23 changes: 23 additions & 0 deletions projects/jest-utils/src/lib/configure-test-suite.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { TestBed, getTestBed, ComponentFixture } from '@angular/core/testing';
import 'jest';

// Ref: https://github.com/angular/angular/issues/12409
export function configureJestSetup() {
const testBedApi: any = getTestBed();
const originReset = TestBed.resetTestingModule;

beforeAll(() => {
TestBed.resetTestingModule();
TestBed.resetTestingModule = () => TestBed;
});

afterEach(() => {
testBedApi._activeFixtures.forEach((fixture: ComponentFixture<any>) => fixture.destroy());
testBedApi._instantiated = false;
});

afterAll(() => {
TestBed.resetTestingModule = originReset;
TestBed.resetTestingModule();
});
}
1 change: 1 addition & 0 deletions projects/jest-utils/src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './configure-test-suite';
5 changes: 5 additions & 0 deletions projects/jest-utils/src/public_api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
* Public API Surface of testing-library
*/

export * from './lib';
27 changes: 27 additions & 0 deletions projects/jest-utils/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/lib",
"target": "es2015",
"module": "es2015",
"moduleResolution": "node",
"declaration": true,
"sourceMap": true,
"inlineSources": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"types": [],
"lib": ["dom", "es2015"]
},
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"flatModuleId": "AUTOGENERATED",
"flatModuleOutFile": "AUTOGENERATED"
},
"exclude": ["src/test.ts", "**/*.spec.ts"]
}
3 changes: 3 additions & 0 deletions projects/jest-utils/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../tslint.json"
}
2 changes: 1 addition & 1 deletion projects/testing-library/ng-package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../@angular-extensions/testing-library",
"dest": "../../dist/@angular-extensions/testing-library",
"deleteDestPath": false,
"lib": {
"entryFile": "src/public_api.ts"
Expand Down
3 changes: 1 addition & 2 deletions projects/testing-library/src/lib/testing-library.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Component, OnInit, ElementRef, Type, DebugElement } from '@angular/core';
import { By } from '@angular/platform-browser';
import { TestBed, ComponentFixture } from '@angular/core/testing';
import { getQueriesForElement, prettyDOM, fireEvent, FireObject, FireFunction } from 'dom-testing-library';

import { RenderResult, RenderOptions } from './models';
import { By } from '@angular/platform-browser';

@Component({ selector: 'wrapper-component', template: '' })
class WrapperComponent implements OnInit {
Expand Down
1 change: 0 additions & 1 deletion projects/testing-library/src/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@

export * from './lib/models';
export * from './lib/testing-library';
export * from './jest-utils';
export * from 'dom-testing-library';
3 changes: 2 additions & 1 deletion src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AppComponent } from './app.component';
import { render, configureJestSetup } from '@angular-extensions/testing-library';
import { render } from '@angular-extensions/testing-library';
import { configureJestSetup } from '@angular-extensions/testing-library/jest-utils';

configureJestSetup();

Expand Down

0 comments on commit 5da50f3

Please sign in to comment.