-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 91597cb
Showing
40 changed files
with
14,751 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Editor configuration, see http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
max_line_length = off | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# See http://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# compiled output | ||
/dist | ||
/tmp | ||
/out-tsc | ||
|
||
# dependencies | ||
/node_modules | ||
|
||
# IDEs and editors | ||
/.idea | ||
.project | ||
.classpath | ||
.c9/ | ||
*.launch | ||
.settings/ | ||
*.sublime-workspace | ||
|
||
# IDE - VSCode | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
|
||
# misc | ||
/.sass-cache | ||
/connect.lock | ||
/coverage | ||
/libpeerconnection.log | ||
npm-debug.log | ||
yarn-error.log | ||
testem.log | ||
/typings | ||
|
||
# System Files | ||
.DS_Store | ||
Thumbs.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# NgxTestingLibraryApp | ||
|
||
Test your Angular components with the [dom-testing-library](https://github.com/kentcdodds/dom-testing-library). | ||
|
||
Go from | ||
|
||
```ts | ||
import { TestBed, async } from '@angular/core/testing'; | ||
import { AppComponent } from './app.component'; | ||
|
||
describe('AppComponent', () => { | ||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [AppComponent], | ||
}).compileComponents(); | ||
})); | ||
|
||
it(`should have as title 'my-awesome-app'`, async(() => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
const app = fixture.debugElement.componentInstance; | ||
expect(app.title).toEqual('my-awesome-app'); | ||
})); | ||
|
||
it('should render title in a h1 tag', async(() => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
fixture.detectChanges(); | ||
const compiled = fixture.debugElement.nativeElement; | ||
expect(compiled.querySelector('h1').textContent).toContain('Welcome to my-awesome-app!'); | ||
})); | ||
}); | ||
``` | ||
|
||
to | ||
|
||
```ts | ||
import { AppComponent } from './app.component'; | ||
import { createComponent } from 'ngx-testing-library'; | ||
|
||
test(`should have as title 'my-awesome-app'`, async () => { | ||
const { detectChanges, getByText } = await createComponent('<app-root></app-root>', { | ||
declarations: [AppComponent], | ||
}); | ||
expect(getByText('Welcome to my-awesome-app!')).toBeDefined(); | ||
}); | ||
|
||
test(`should render title in a h1 tag`, async () => { | ||
const { container } = await createComponent('<app-root></app-root>', { | ||
declarations: [AppComponent], | ||
}); | ||
expect(container.querySelector('h1').textContent).toContain('Welcome to my-awesome-app!'); | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
{ | ||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json", | ||
"version": 1, | ||
"newProjectRoot": "projects", | ||
"projects": { | ||
"ngx-testing-library-app": { | ||
"root": "", | ||
"sourceRoot": "src", | ||
"projectType": "application", | ||
"prefix": "app", | ||
"schematics": {}, | ||
"architect": { | ||
"build": { | ||
"builder": "@angular-devkit/build-angular:browser", | ||
"options": { | ||
"outputPath": "dist/ngx-testing-library-app", | ||
"index": "src/index.html", | ||
"main": "src/main.ts", | ||
"polyfills": "src/polyfills.ts", | ||
"tsConfig": "src/tsconfig.app.json", | ||
"assets": ["src/favicon.ico", "src/assets"], | ||
"styles": ["src/styles.css"], | ||
"scripts": [] | ||
}, | ||
"configurations": { | ||
"production": { | ||
"fileReplacements": [ | ||
{ | ||
"replace": "src/environments/environment.ts", | ||
"with": "src/environments/environment.prod.ts" | ||
} | ||
], | ||
"optimization": true, | ||
"outputHashing": "all", | ||
"sourceMap": false, | ||
"extractCss": true, | ||
"namedChunks": false, | ||
"aot": true, | ||
"extractLicenses": true, | ||
"vendorChunk": false, | ||
"buildOptimizer": true | ||
} | ||
} | ||
}, | ||
"serve": { | ||
"builder": "@angular-devkit/build-angular:dev-server", | ||
"options": { | ||
"browserTarget": "ngx-testing-library-app:build" | ||
}, | ||
"configurations": { | ||
"production": { | ||
"browserTarget": "ngx-testing-library-app:build:production" | ||
} | ||
} | ||
}, | ||
"extract-i18n": { | ||
"builder": "@angular-devkit/build-angular:extract-i18n", | ||
"options": { | ||
"browserTarget": "ngx-testing-library-app:build" | ||
} | ||
}, | ||
"lint": { | ||
"builder": "@angular-devkit/build-angular:tslint", | ||
"options": { | ||
"tsConfig": ["src/tsconfig.app.json", "./tsconfig.spec.json"], | ||
"exclude": ["**/node_modules/**"] | ||
} | ||
} | ||
} | ||
}, | ||
"ngx-testing-library": { | ||
"root": "projects/ngx-testing-library", | ||
"sourceRoot": "projects/ngx-testing-library/src", | ||
"projectType": "library", | ||
"prefix": "lib", | ||
"architect": { | ||
"build": { | ||
"builder": "@angular-devkit/build-ng-packagr:build", | ||
"options": { | ||
"tsConfig": "projects/ngx-testing-library/tsconfig.lib.json", | ||
"project": "projects/ngx-testing-library/ng-package.json" | ||
}, | ||
"configurations": { | ||
"production": { | ||
"project": "projects/ngx-testing-library/ng-package.prod.json" | ||
} | ||
} | ||
}, | ||
"lint": { | ||
"builder": "@angular-devkit/build-angular:tslint", | ||
"options": { | ||
"tsConfig": ["projects/ngx-testing-library/tsconfig.lib.json", "./tsconfig.spec.json"], | ||
"exclude": ["**/node_modules/**"] | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"defaultProject": "ngx-testing-library-app" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const baseConfig = require('./jest.base.config'); | ||
|
||
module.exports = { | ||
...baseConfig, | ||
roots: ['<rootDir>/src'], | ||
modulePathIgnorePatterns: ['<rootDir>/projects'], | ||
moduleNameMapper: { | ||
'ngx-testing-library': '<rootDir>/dist/ngx-testing-library', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
preset: 'jest-preset-angular', | ||
setupTestFrameworkScriptFile: '<rootDir>/test.ts', | ||
globals: { | ||
'ts-jest': { | ||
tsConfigFile: './tsconfig.spec.json', | ||
}, | ||
__TRANSFORM_HTML__: true, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const baseConfig = require('./jest.base.config'); | ||
|
||
module.exports = { | ||
...baseConfig, | ||
roots: ['<rootDir>/projects'], | ||
}; |
Oops, something went wrong.