Skip to content

fix: don't include jest-utils in main package #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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