Use Angular CLI instead of ngm for building
Some commands: npm run build - to build the library. Output is in dist/ng2-file-upload/. npm run test - to run tests. Coverage report is in coverage/ as before. npm run demo.serve - to build demo application and serve it through browsersync npm run start - to run demo application using `ng serve`. Requires the library to be built and linked first.
This commit is contained in:
committed by
Evgeny Arshinov
parent
6cb3f87e57
commit
7a342268bb
72
test/karma.conf.js
Normal file
72
test/karma.conf.js
Normal file
@@ -0,0 +1,72 @@
|
||||
// Karma configuration file, see link for more information
|
||||
// https://karma-runner.github.io/0.13/config/configuration-file.html
|
||||
|
||||
const customLaunchers = require('./sauce-browsers').customLaunchers;
|
||||
|
||||
module.exports = function (config) {
|
||||
const configuration = {
|
||||
basePath: '',
|
||||
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
||||
plugins: [
|
||||
require('karma-jasmine'),
|
||||
require('karma-chrome-launcher'),
|
||||
require('karma-coverage-istanbul-reporter'),
|
||||
require('@angular-devkit/build-angular/plugins/karma')
|
||||
],
|
||||
coverageIstanbulReporter: {
|
||||
dir: require('path').join(__dirname, '../coverage'), reports: [ 'html', 'lcovonly' ],
|
||||
fixWebpackSourcePaths: false
|
||||
},
|
||||
|
||||
reporters: ['dots', 'coverage-istanbul'],
|
||||
port: 9876,
|
||||
colors: true,
|
||||
logLevel: config.LOG_INFO,
|
||||
autoWatch: true,
|
||||
browsers: ['Chrome'],
|
||||
singleRun: true,
|
||||
customLaunchers: {
|
||||
Chrome_travis_ci: {
|
||||
base: 'Chrome',
|
||||
flags: ['--no-sandbox']
|
||||
}
|
||||
},
|
||||
mime: { 'text/x-typescript': ['ts','tsx'] },
|
||||
client: { captureConsole: true }
|
||||
};
|
||||
|
||||
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'));
|
||||
configuration.reporters.push('saucelabs');
|
||||
configuration.sauceLabs = {
|
||||
verbose: true,
|
||||
testName: 'ng2-bootstrap unit tests',
|
||||
recordScreenshots: false,
|
||||
username: process.env.SAUCE_USERNAME,
|
||||
accessKey: process.env.SAUCE_ACCESS_KEY,
|
||||
connectOptions: {
|
||||
port: 5757,
|
||||
logfile: 'sauce_connect.log'
|
||||
},
|
||||
public: 'public'
|
||||
};
|
||||
configuration.captureTimeout = 0;
|
||||
configuration.customLaunchers = customLaunchers();
|
||||
configuration.browsers = Object.keys(configuration.customLaunchers);
|
||||
configuration.concurrency = 3;
|
||||
configuration.browserDisconnectTolerance = 2;
|
||||
configuration.browserNoActivityTimeout = 20000;
|
||||
configuration.browserDisconnectTimeout = 5000;
|
||||
}
|
||||
|
||||
config.set(configuration);
|
||||
};
|
||||
21
test/matchers.ts
Normal file
21
test/matchers.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
// tslint:disable
|
||||
/**
|
||||
* @copyright Angular ng-bootstrap team
|
||||
*/
|
||||
beforeEach(() => {
|
||||
jasmine.addMatchers({
|
||||
toHaveCssClass(/*util, customEqualityTests*/) {
|
||||
return {compare: buildError(false), negativeCompare: buildError(true)};
|
||||
|
||||
function buildError(isNot) {
|
||||
return function (actual, className) {
|
||||
const orNot = isNot ? 'not ' : '';
|
||||
return {
|
||||
pass: actual.classList.contains(className) === !isNot,
|
||||
message: `Expected ${actual.outerHTML} ${orNot} to contain the CSS class "${className}"`
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
18
test/sauce-browsers.js
Normal file
18
test/sauce-browsers.js
Normal file
@@ -0,0 +1,18 @@
|
||||
module.exports.customLaunchers = function customLaunchers() {
|
||||
return {
|
||||
sl_chrome: {base: 'SauceLabs', browserName: 'chrome'},
|
||||
sl_chrome_1: {base: 'SauceLabs', browserName: 'chrome', version: 'latest-1'},
|
||||
sl_firefox: {base: 'SauceLabs', browserName: 'firefox'},
|
||||
sl_firefox_1: {base: 'SauceLabs', browserName: 'firefox', version: 'latest-1'},
|
||||
sl_ie9: {base: 'SauceLabs', browserName: 'internet explorer', platform: 'Windows 2008', version: '9'},
|
||||
'SL_IE10': {base: 'SauceLabs', browserName: 'internet explorer', platform: 'Windows 2012', version: '10'},
|
||||
'SL_IE11': {base: 'SauceLabs', browserName: 'internet explorer', platform: 'Windows 8.1', version: '11'},
|
||||
'SL_EDGE': {base: 'SauceLabs', browserName: 'MicrosoftEdge', platform: 'Windows 10', version: '13.10586'},
|
||||
'SL_IOS9': {base: 'SauceLabs', browserName: 'iphone', platform: 'OS X 10.10', version: '9.3'},
|
||||
'SL_IOS10': {base: 'SauceLabs', browserName: 'iphone', platform: 'OS X 10.10', version: '10.0'},
|
||||
'SL_ANDROID4.4': {base: 'SauceLabs', browserName: 'android', platform: 'Linux', version: '4.4'},
|
||||
'SL_ANDROID5': {base: 'SauceLabs', browserName: 'android', platform: 'Linux', version: '5.1'},
|
||||
'SL_SAFARI9': {base: 'SauceLabs', browserName: 'safari', platform: 'OS X 10.11', version: '9.0'}
|
||||
};
|
||||
};
|
||||
|
||||
37
test/test.ts
Normal file
37
test/test.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import '../scripts/polyfills.ts';
|
||||
|
||||
import 'zone.js/dist/long-stack-trace-zone';
|
||||
import 'zone.js/dist/proxy.js';
|
||||
import 'zone.js/dist/sync-test';
|
||||
import 'zone.js/dist/jasmine-patch';
|
||||
import 'zone.js/dist/async-test';
|
||||
import 'zone.js/dist/fake-async-test';
|
||||
import { getTestBed } from '@angular/core/testing';
|
||||
import {
|
||||
BrowserDynamicTestingModule,
|
||||
platformBrowserDynamicTesting
|
||||
} from '@angular/platform-browser-dynamic/testing';
|
||||
|
||||
import './matchers';
|
||||
|
||||
// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
|
||||
declare var __karma__: any;
|
||||
declare var require: any;
|
||||
|
||||
// Prevent Karma from running prematurely.
|
||||
__karma__.loaded = Function.prototype;
|
||||
|
||||
// First, initialize the Angular testing environment.
|
||||
getTestBed().initTestEnvironment(
|
||||
BrowserDynamicTestingModule,
|
||||
platformBrowserDynamicTesting()
|
||||
);
|
||||
// Then we find all the tests.
|
||||
let context = require.context('../demo/src', true, /\.spec\.ts/);
|
||||
// And load the modules.
|
||||
context.keys().map(context);
|
||||
|
||||
let context2 = require.context('../src/spec', true, /\.spec\.ts/);
|
||||
context2.keys().map(context2);
|
||||
// Finally, start Karma to run the tests.
|
||||
__karma__.start();
|
||||
22
test/tsconfig.json
Normal file
22
test/tsconfig.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"target": "es2015",
|
||||
"outDir": "./out-tsc/spec",
|
||||
"types": [
|
||||
"jasmine",
|
||||
"node"
|
||||
]
|
||||
},
|
||||
"files": [
|
||||
"../scripts/typings.d.ts",
|
||||
"test.ts",
|
||||
"../scripts/polyfills.ts",
|
||||
],
|
||||
"include": [
|
||||
"../src/**/*.spec.ts",
|
||||
"../demo/src/**/*.spec.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user