Skip to content

Commit

Permalink
feat(environments): add test environment, skip debug meta-reducer in …
Browse files Browse the repository at this point in the history
…tests
  • Loading branch information
tomastrajan committed Jun 9, 2018
1 parent b862590 commit 7205db2
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 7 deletions.
10 changes: 10 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@
"output": "/assets"
}
]
},
"configurations": {
"test": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.test.ts"
}
]
}
}
},
"lint": {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"ng": "ng",
"start": "ng serve --open",
"build": "ng build",
"test": "npm run lint && ng test",
"test": "npm run lint && ng test --configuration=test",
"lint": "ng lint",
"e2e": "ng e2e",
"watch": "ng test --browsers ChromeHeadless --watch",
"watch": "ng test --configuration=test --browsers ChromeHeadless --watch",
"build:prod": "ng build --prod --build-optimizer --vendor-chunk --common-chunk",
"clean": "rimraf ./dist/",
"server": "cd dist && http-server",
Expand Down
5 changes: 4 additions & 1 deletion src/app/core/core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import { AnimationsService } from './animations/animations.service';
export const metaReducers: MetaReducer<any>[] = [initStateFromLocalStorage];

if (!environment.production) {
metaReducers.unshift(debug, storeFreeze);
metaReducers.unshift(storeFreeze);
if (!environment.test) {
metaReducers.unshift(debug);
}
}

@NgModule({
Expand Down
1 change: 1 addition & 0 deletions src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const environment = {
appName: 'Angular Ngrx Material Starter',
envName: 'PROD',
production: true,
test: false,
versions: {
app: packageJson.version,
angular: packageJson.dependencies['@angular/core'],
Expand Down
20 changes: 20 additions & 0 deletions src/environments/environment.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const packageJson = require('../../package.json');

export const environment = {
appName: 'Angular Ngrx Material Starter',
envName: 'TEST',
production: false,
test: true,
versions: {
app: packageJson.version,
angular: packageJson.dependencies['@angular/core'],
ngrx: packageJson.dependencies['@ngrx/store'],
material: packageJson.dependencies['@angular/material'],
bootstrap: packageJson.dependencies.bootstrap,
rxjs: packageJson.dependencies.rxjs,
fontAwesome:
packageJson.dependencies['@fortawesome/fontawesome-free-webfonts'],
angularCli: packageJson.devDependencies['@angular/cli'],
typescript: packageJson.devDependencies['typescript']
}
};
1 change: 1 addition & 0 deletions src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const environment = {
appName: 'Angular Ngrx Material Starter',
envName: 'DEV',
production: false,
test: false,
versions: {
app: packageJson.version,
angular: packageJson.dependencies['@angular/core'],
Expand Down
5 changes: 1 addition & 4 deletions src/karma.conf.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ module.exports = function (config) {
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: ['progress', 'kjhtml', 'spec'],
reporters: ['spec'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
Expand Down

0 comments on commit 7205db2

Please sign in to comment.