simplify build setup to use the main tsconfig.json file for tests
This commit is contained in:
parent
6394f9e1ed
commit
4e9d52a044
@ -1,4 +1,11 @@
|
|||||||
import { newApp, newLib, newProject, runCLI, updateFile } from '../utils';
|
import {
|
||||||
|
newApp,
|
||||||
|
newLib,
|
||||||
|
newProject,
|
||||||
|
runCLI,
|
||||||
|
updateFile,
|
||||||
|
runCommand
|
||||||
|
} from '../utils';
|
||||||
|
|
||||||
describe('Nrwl Workspace', () => {
|
describe('Nrwl Workspace', () => {
|
||||||
it(
|
it(
|
||||||
@ -32,6 +39,21 @@ describe('Nrwl Workspace', () => {
|
|||||||
1000000
|
1000000
|
||||||
);
|
);
|
||||||
|
|
||||||
|
it('should only run unit tests for all apps and e2e tests for a single app', () => {
|
||||||
|
newProject();
|
||||||
|
newApp('myapp');
|
||||||
|
|
||||||
|
try {
|
||||||
|
runCommand('npm run test -- --app myapp --single-run', true);
|
||||||
|
fail('boom');
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
try {
|
||||||
|
runCommand('npm run e2e', true);
|
||||||
|
fail('boom');
|
||||||
|
} catch (e) {}
|
||||||
|
});
|
||||||
|
|
||||||
it(
|
it(
|
||||||
'should support router config generation (lazy)',
|
'should support router config generation (lazy)',
|
||||||
() => {
|
() => {
|
||||||
|
|||||||
@ -228,47 +228,4 @@ describe('Command line', () => {
|
|||||||
},
|
},
|
||||||
1000000
|
1000000
|
||||||
);
|
);
|
||||||
|
|
||||||
describe('Testing:', () => {
|
|
||||||
beforeAll(() => {
|
|
||||||
newProject();
|
|
||||||
newApp('app1');
|
|
||||||
}, 1000000);
|
|
||||||
|
|
||||||
it('should pass tests', () => {
|
|
||||||
expect(runCommand('npm run test -- --single-run').toString()).toContain(
|
|
||||||
'Executed 1 of 1 SUCCESS'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not be able to run tests on an individual app', () => {
|
|
||||||
try {
|
|
||||||
expect(runCommand('npm run test -- --app app1 --single-run'));
|
|
||||||
fail('boom');
|
|
||||||
} catch (e) {
|
|
||||||
const errorOutput = e.stderr.toString();
|
|
||||||
expect(errorOutput).toContain(
|
|
||||||
'Nx only supports running unit tests for all apps and libs.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should pass e2e tests', () => {
|
|
||||||
expect(runCommand('npm run e2e -- --app app1').toString()).toContain(
|
|
||||||
'should display welcome message'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not be able to run e2e tests without specifying an app', () => {
|
|
||||||
try {
|
|
||||||
expect(runCommand('npm run e2e'));
|
|
||||||
fail('boom');
|
|
||||||
} catch (e) {
|
|
||||||
const errorOutput = e.stderr.toString();
|
|
||||||
expect(errorOutput).toContain(
|
|
||||||
'Please provide the app name using --app or -a.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -106,8 +106,11 @@ export function runSchematic(command: string): string {
|
|||||||
}).toString();
|
}).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function runCommand(command: string): string {
|
export function runCommand(command: string, silent?: boolean): string {
|
||||||
return execSync(command, { cwd: `./tmp/${projectName}` }).toString();
|
return execSync(command, {
|
||||||
|
cwd: `./tmp/${projectName}`,
|
||||||
|
...(silent ? { stdio: ['ignore', 'ignore', 'ignore'] } : {})
|
||||||
|
}).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateFile(f: string, content: string): void {
|
export function updateFile(f: string, content: string): void {
|
||||||
|
|||||||
@ -20,7 +20,7 @@ module.exports = function(config) {
|
|||||||
frameworks: ['jasmine'],
|
frameworks: ['jasmine'],
|
||||||
|
|
||||||
// list of files / patterns to load in the browser
|
// list of files / patterns to load in the browser
|
||||||
files: [{ pattern: 'test/test.js', watched: false }],
|
files: [{ pattern: 'build/test.js', watched: false }],
|
||||||
|
|
||||||
// list of files to exclude
|
// list of files to exclude
|
||||||
exclude: [],
|
exclude: [],
|
||||||
@ -28,7 +28,7 @@ module.exports = function(config) {
|
|||||||
// preprocess matching files before serving them to the browser
|
// preprocess matching files before serving them to the browser
|
||||||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
|
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
|
||||||
preprocessors: {
|
preprocessors: {
|
||||||
'test/test.js': ['webpack']
|
'build/test.js': ['webpack']
|
||||||
},
|
},
|
||||||
|
|
||||||
reporters: ['dots'],
|
reporters: ['dots'],
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
"test:schematics": "yarn linknpm fast && ./scripts/test_schematics.sh",
|
"test:schematics": "yarn linknpm fast && ./scripts/test_schematics.sh",
|
||||||
"test:nx": "yarn linknpm fast && ./scripts/test_nx.sh",
|
"test:nx": "yarn linknpm fast && ./scripts/test_nx.sh",
|
||||||
"test":
|
"test":
|
||||||
"yarn linknpm && ./scripts/test_nx.sh && ./scripts/test_schematics.sh",
|
"yarn linknpm fast && ./scripts/test_nx.sh && ./scripts/test_schematics.sh",
|
||||||
"checkformat": "prettier \"{packages,e2e}/**/*.ts\" --list-different",
|
"checkformat": "prettier \"{packages,e2e}/**/*.ts\" --list-different",
|
||||||
"publish_npm": "./scripts/publish.sh"
|
"publish_npm": "./scripts/publish.sh"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,11 +1,6 @@
|
|||||||
import { Component, Injectable } from '@angular/core';
|
import { Component, Injectable } from '@angular/core';
|
||||||
import {
|
import { fakeAsync, TestBed, tick } from '@angular/core/testing';
|
||||||
ComponentFixture,
|
import { Router } from '@angular/router';
|
||||||
fakeAsync,
|
|
||||||
TestBed,
|
|
||||||
tick
|
|
||||||
} from '@angular/core/testing';
|
|
||||||
import { ActivatedRouteSnapshot, Router } from '@angular/router';
|
|
||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
import { Actions, Effect, EffectsModule } from '@ngrx/effects';
|
import { Actions, Effect, EffectsModule } from '@ngrx/effects';
|
||||||
import { provideMockActions } from '@ngrx/effects/testing';
|
import { provideMockActions } from '@ngrx/effects/testing';
|
||||||
@ -545,7 +540,3 @@ describe('DataPersistence', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function createRoot(router: Router, type: any): ComponentFixture<any> {
|
|
||||||
return TestBed.createComponent(type);
|
|
||||||
}
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { Injectable, Type } from '@angular/core';
|
|||||||
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
|
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
|
||||||
import { Actions } from '@ngrx/effects';
|
import { Actions } from '@ngrx/effects';
|
||||||
import { ROUTER_NAVIGATION, RouterNavigationAction } from '@ngrx/router-store';
|
import { ROUTER_NAVIGATION, RouterNavigationAction } from '@ngrx/router-store';
|
||||||
import { Action, State, Store } from '@ngrx/store';
|
import { Action, Store } from '@ngrx/store';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { of } from 'rxjs/observable/of';
|
import { of } from 'rxjs/observable/of';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@ -5,8 +5,8 @@ rm -rf build
|
|||||||
./node_modules/.bin/ngc
|
./node_modules/.bin/ngc
|
||||||
|
|
||||||
#Nx client side lib
|
#Nx client side lib
|
||||||
|
rm -rf build/packages/nx
|
||||||
cp -r packages/nx/dist build/packages/nx
|
cp -r packages/nx/dist build/packages/nx
|
||||||
rm -rf build/packages/nx/dist
|
|
||||||
rm -rf packages/nx/dist
|
rm -rf packages/nx/dist
|
||||||
|
|
||||||
#TODO This is a temporary hack until we can publish named umds
|
#TODO This is a temporary hack until we can publish named umds
|
||||||
|
|||||||
@ -7,14 +7,5 @@ if [ "$1" != "fast" ]; then
|
|||||||
./scripts/build.sh
|
./scripts/build.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -rf node_modules/@nrwl
|
|
||||||
cp -r build/packages node_modules/@nrwl
|
|
||||||
|
|
||||||
rm -rf test/
|
|
||||||
|
|
||||||
tsc -p tsconfig.spec.json
|
|
||||||
|
|
||||||
rsync -a --exclude=*.ts packages/ test/packages
|
|
||||||
|
|
||||||
rm -rf node_modules/@nrwl
|
rm -rf node_modules/@nrwl
|
||||||
cp -r build/packages node_modules/@nrwl
|
cp -r build/packages node_modules/@nrwl
|
||||||
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if [ -n "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
jest --maxWorkers=1 ./test/packages/$1.spec.js
|
jest --maxWorkers=1 ./build/packages/$1.spec.js
|
||||||
else
|
else
|
||||||
jest --maxWorkers=1 ./test/packages/{schematics,bazel}
|
jest --maxWorkers=1 ./build/packages/{schematics,bazel}
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -20,8 +20,7 @@
|
|||||||
"exclude": [
|
"exclude": [
|
||||||
"tmp",
|
"tmp",
|
||||||
"node_modules",
|
"node_modules",
|
||||||
"packages/schematics/src/*/files/**/*",
|
"packages/schematics/src/*/files/**/*"
|
||||||
"packages/nx"
|
|
||||||
],
|
],
|
||||||
"angularCompilerOptions": {
|
"angularCompilerOptions": {
|
||||||
"strictMetadataEmit": true,
|
"strictMetadataEmit": true,
|
||||||
|
|||||||
@ -1,21 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"target": "es5",
|
|
||||||
"module": "commonjs",
|
|
||||||
"moduleResolution": "node",
|
|
||||||
"outDir": "test",
|
|
||||||
"typeRoots": ["node_modules/@types"],
|
|
||||||
"experimentalDecorators": true,
|
|
||||||
"emitDecoratorMetadata": true,
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"lib": ["es2017"],
|
|
||||||
"declaration": true,
|
|
||||||
"baseUrl": "."
|
|
||||||
},
|
|
||||||
"exclude": ["tmp", "node_modules"],
|
|
||||||
"angularCompilerOptions": {
|
|
||||||
"strictMetadataEmit": true,
|
|
||||||
"skipTemplateCodegen": true,
|
|
||||||
"annotationsAs": "decorators"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user