Skip to content

Commit

Permalink
fix(chore ci): change sourceRoot to deepen ng cli run scope, add ampe… (
Browse files Browse the repository at this point in the history
#5674)

* fix(chore ci): change sourceRoot to deepen ng cli run scope, add ampersands to prevent multiple scopes in script run.

* fix(chore ci): split tests run in different applications, fix demo tests to prevent Errors while no tests in test-run.

* fix(chore ci): fix variable usage in base config.

* fix(chore ci): revert sourceRoot for demo project.

Co-authored-by: Dmitriy Danilov <daniloff200@gmail.com>
Co-authored-by: Irina Ershova <ershova.ira92@gmail.com>
  • Loading branch information
3 people authored Feb 20, 2020
1 parent 4ba64f0 commit 198cdf1
Show file tree
Hide file tree
Showing 9 changed files with 218 additions and 143 deletions.
49 changes: 48 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "scripts/test.ts",
"main": "scripts/test-demo.ts",
"karmaConfig": "karma-demo.conf.js",
"polyfills": "demo/src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
Expand Down Expand Up @@ -151,6 +151,53 @@
}
}
}
},
"ngx-bootstrap-source": {
"root": "",
"sourceRoot": "src",
"projectType": "library",
"architect": {
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "scripts/test-source.ts",
"karmaConfig": "karma-source.conf.js",
"polyfills": "demo/src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"codeCoverageExclude": ["dist/**/*"],
"sourceMap": false,
"scripts": [],
"styles": [
"src/datepicker/bs-datepicker.scss",
"demo/src/assets/css/style.scss",
"demo/src/assets/css/prettify-angulario.css"
],
"assets": []
},
"configurations": {
"ivy": {
"tsConfig": "src/tsconfig-ivy.spec.json"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"../tslint.json"
],
"exclude": []
}
},
"server": {
"builder": "@angular-devkit/build-angular:server",
"options": {
"outputPath": "demo/dist/server",
"main": "demo/src/main.server.ts",
"tsConfig": "demo/src/tsconfig.server.json"
}
}
}
}
},
"defaultProject": "ngx-bootstrap",
Expand Down
41 changes: 13 additions & 28 deletions demo/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,23 @@
import { TestBed, async } from '@angular/core/testing';
import { TestBed, async, ComponentFixture } from '@angular/core/testing';
import { AppComponent } from './app.component';
import { AppModule } from './app.module';

describe('App: Ng2Bootstrap', () => {
let fixture: ComponentFixture<AppComponent>;
/* tslint:disable-next-line: no-any */
let context: any;

xdescribe('App: Ng2Bootstrap', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [AppComponent]
imports: [AppModule]
});
});

it(
'should create the app',
async(() => {
let fixture = TestBed.createComponent(AppComponent);
let app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
})
);

it(
`should have as title 'app works!'`,
async(() => {
let fixture = TestBed.createComponent(AppComponent);
let app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('app works!');
})
);
fixture = TestBed.createComponent(AppComponent);
context = fixture.componentInstance;
});

it(
'should render title in a h1 tag',
async(() => {
let fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
let compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('app works!');
it('should create the app', (() => {
expect(context).toBeTruthy();
})
);
});
118 changes: 8 additions & 110 deletions karma-demo.conf.js
Original file line number Diff line number Diff line change
@@ -1,113 +1,11 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html

module.exports = function (config) {
const configuration = {
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-firefox-launcher'),
require('karma-ie-launcher'),
require('karma-edge-launcher'),
require('karma-safari-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
coverageIstanbulReporter: {
dir: require('path').join(__dirname, 'coverage'),
reports: ['html', 'lcovonly', 'text'],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: config.angularCli && config.angularCli.codeCoverage
? ['dots', 'coverage-istanbul']
: ['dots', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['ChromeHeadless'],
browserNoActivityTimeout: 20000,
browserDisconnectTolerance: 2,
browserDisconnectTimeout: 5000,
singleRun: true,
customLaunchers: {
Chrome_travis_ci: {
base: 'ChromeHeadless',
flags: [
'--headless',
'--disable-gpu',
'--no-sandbox',
'--remote-debugging-port=9222'
]
}
},
mime: {'text/x-typescript': ['ts', 'tsx']},
client: {captureConsole: true, clearContext: false}
};

if (process.env.TRAVIS) {
configuration.browsers = ['Chrome_travis_ci'];
}

if (process.env.SAUCE) {
if (!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY) {
console.log('Make sure the SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables are set.');
process.exit(1);
}

configuration.plugins.push(require('karma-sauce-launcher'));
Object.assign(configuration, {
logLevel: config.LOG_INFO,
reporters: ['dots', 'saucelabs'],
singleRun: true,
concurrency: 4,
captureTimeout: 60000,
sauceLabs: {
testName: 'ngx-bootstrap',
build: process.env.TRAVIS_JOB_NUMBER,
tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER,
// retryLimit: 5,
startConnect: false,
recordVideo: false,
recordScreenshots: false,
options: {
'command-timeout': 600,
'idle-timeout': 600,
'max-duration': 5400
}
},
customLaunchers: {
//LATEST
'SL_FIREFOX': {
base: 'SauceLabs',
browserName: 'firefox',
version: 'latest'
},
'SL_IE11': {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 8.1',
version: '11.0'
},
'SL_EDGE': {
base: 'SauceLabs',
browserName: 'MicrosoftEdge',
version: 'latest'
},
'SL_SAFARI': {
base: 'SauceLabs',
browserName: 'safari',
version: '11'
}
}
});
configuration.browsers = Object.keys(configuration.customLaunchers);
}
config.set(configuration);
};
module.exports = require('./karma.base.conf')({
coverageIstanbulReporter: {
dir: require('path').join(__dirname, 'coverage/demo'),
reports: ['html', 'lcovonly', 'text'],
fixWebpackSourcePaths: true
},
port: 9876,
});
11 changes: 11 additions & 0 deletions karma-source.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html

module.exports = require('./karma.base.conf')({
coverageIstanbulReporter: {
dir: require('path').join(__dirname, 'coverage/source'),
reports: ['html', 'lcovonly', 'text'],
fixWebpackSourcePaths: true
},
port: 9875,
});
116 changes: 116 additions & 0 deletions karma.base.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html

module.exports = function(projectConfig) {
return function (config) {
const baseConfiguration = {
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-firefox-launcher'),
require('karma-ie-launcher'),
require('karma-edge-launcher'),
require('karma-safari-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
coverageIstanbulReporter: {
dir: require('path').join(__dirname, 'coverage'),
reports: ['html', 'lcovonly', 'text'],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: config.angularCli && config.angularCli.codeCoverage
? ['dots', 'coverage-istanbul']
: ['dots', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['ChromeHeadless'],
browserNoActivityTimeout: 20000,
browserDisconnectTolerance: 2,
browserDisconnectTimeout: 5000,
singleRun: true,
customLaunchers: {
Chrome_travis_ci: {
base: 'ChromeHeadless',
flags: [
'--headless',
'--disable-gpu',
'--no-sandbox',
'--remote-debugging-port=9222'
]
}
},
mime: {'text/x-typescript': ['ts', 'tsx']},
client: {captureConsole: true, clearContext: false}
};

if (process.env.TRAVIS) {
baseConfiguration.browsers = ['Chrome_travis_ci'];
}

if (process.env.SAUCE) {
if (!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY) {
console.log('Make sure the SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables are set.');
process.exit(1);
}

baseConfiguration.plugins.push(require('karma-sauce-launcher'));
Object.assign(baseConfiguration, {
logLevel: config.LOG_INFO,
reporters: ['dots', 'saucelabs'],
singleRun: true,
concurrency: 4,
captureTimeout: 60000,
sauceLabs: {
testName: 'ngx-bootstrap',
build: process.env.TRAVIS_JOB_NUMBER,
tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER,
// retryLimit: 5,
startConnect: false,
recordVideo: false,
recordScreenshots: false,
options: {
'command-timeout': 600,
'idle-timeout': 600,
'max-duration': 5400
}
},
customLaunchers: {
//LATEST
'SL_FIREFOX': {
base: 'SauceLabs',
browserName: 'firefox',
version: 'latest'
},
'SL_IE11': {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 8.1',
version: '11.0'
},
'SL_EDGE': {
base: 'SauceLabs',
browserName: 'MicrosoftEdge',
version: 'latest'
},
'SL_SAFARI': {
base: 'SauceLabs',
browserName: 'safari',
version: '11'
}
}
});
baseConfiguration.browsers = Object.keys(baseConfiguration.customLaunchers);
}

config.set(Object.assign({}, baseConfiguration, projectConfig));
};
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"test": "ng test && npm run test:schematics",
"test:ivy": "ng test --configuration ivy && npm run test:schematics",
"test:schematics": "jasmine schematics/src/**/*.spec.js",
"test-cross": "SAUCE=true ng test",
"test-cross": "SAUCE=true && ng test",
"test-coverage": "ng test --code-coverage",
"version": "node scripts/version && npm run version.changelog",
"version.changelog": "run-s changelog git-add git-commit-changelog",
Expand Down
2 changes: 0 additions & 2 deletions scripts/test.ts → scripts/test-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,5 @@ const context = require.context('../demo/src', true, /\.spec\.ts/);
// And load the modules.
context.keys().map(context);

const context2 = require.context('../src', true, /\.spec\.ts/);
context2.keys().map(context2);
// Finally, start Karma to run the tests.
// __karma__.start();
Loading

0 comments on commit 198cdf1

Please sign in to comment.