test: move testing-related files into test dir
|
@ -12,7 +12,7 @@
|
||||||
"main": "app/main.ts",
|
"main": "app/main.ts",
|
||||||
"polyfills": "polyfills.ts",
|
"polyfills": "polyfills.ts",
|
||||||
"test": "test.ts",
|
"test": "test.ts",
|
||||||
"tsconfig": "../tsconfig.json",
|
"tsconfig": "./tsconfig.json",
|
||||||
"testTsconfig": "tsconfig.spec.json",
|
"testTsconfig": "tsconfig.spec.json",
|
||||||
"prefix": "app",
|
"prefix": "app",
|
||||||
"scripts": [],
|
"scripts": [],
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
],
|
],
|
||||||
"e2e": {
|
"e2e": {
|
||||||
"protractor": {
|
"protractor": {
|
||||||
"config": "./protractor.conf.js"
|
"config": "test/protractor.conf.js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lint": [
|
"lint": [
|
||||||
|
@ -34,13 +34,13 @@
|
||||||
"exclude": "**/node_modules/**"
|
"exclude": "**/node_modules/**"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"project": "e2e/tsconfig.e2e.json",
|
"project": "test/e2e/tsconfig.e2e.json",
|
||||||
"exclude": "**/node_modules/**"
|
"exclude": "**/node_modules/**"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"test": {
|
"test": {
|
||||||
"karma": {
|
"karma": {
|
||||||
"config": "./karma.conf.js"
|
"config": "test/karma.conf.js"
|
||||||
},
|
},
|
||||||
"codeCoverage": {
|
"codeCoverage": {
|
||||||
"exclude": [
|
"exclude": [
|
||||||
|
|
|
@ -31,10 +31,10 @@ src/assets/i18n/crowdin_api_key.txt
|
||||||
src/index.html
|
src/index.html
|
||||||
src/manifest.json
|
src/manifest.json
|
||||||
|
|
||||||
test/latest
|
test/visual/latest
|
||||||
test/diffs
|
test/visual/diffs
|
||||||
test/report.html
|
test/visual/report.html
|
||||||
test/report.json
|
test/visual/report.json
|
||||||
junitresults.xml
|
junitresults.xml
|
||||||
|
|
||||||
.sourcemaps/
|
.sourcemaps/
|
||||||
|
|
|
@ -36,9 +36,9 @@
|
||||||
"test": "test:lint && npm run test:ci && npm run e2e:capture-latest && npm run test:visual",
|
"test": "test:lint && npm run test:ci && npm run e2e:capture-latest && npm run test:visual",
|
||||||
"test:coverage": "ng test --code-coverage",
|
"test:coverage": "ng test --code-coverage",
|
||||||
"test:ci": "ng test --watch=false --code-coverage --no-progress",
|
"test:ci": "ng test --watch=false --code-coverage --no-progress",
|
||||||
"test:lint": "tslint --project . --format codeFrame && tslint '{e2e,test,electron,src}/**/*.ts' --format codeFrame && prettier --list-different '{*,**/*}.{js,ts,md,json,scss}'",
|
"test:lint": "tslint --project . --format codeFrame && tslint '{test,electron,src}/**/*.ts' --format codeFrame && prettier --list-different '{*,**/*}.{js,ts,md,json,scss}'",
|
||||||
"test:visual": "cd test && reg-cli latest approved diffs --report report.html --json report.json --enableAntialias --thresholdRate 0.005",
|
"test:visual": "cd test/visual && reg-cli latest approved diffs --report report.html --json report.json --enableAntialias --thresholdRate 0.005",
|
||||||
"fix:tslint": "tslint --fix --project . && tslint --fix '{e2e,test,electron,src}/**/*.ts'",
|
"fix:tslint": "tslint --fix --project . && tslint --fix '{test,electron,src}/**/*.ts'",
|
||||||
"fix:prettier": "prettier --write '{*,**/*}.{js,ts,md,json,scss}'",
|
"fix:prettier": "prettier --write '{*,**/*}.{js,ts,md,json,scss}'",
|
||||||
"e2e": "npm run ionic:build && npm run e2e:test",
|
"e2e": "npm run ionic:build && npm run e2e:test",
|
||||||
"e2e:test": "protractor",
|
"e2e:test": "protractor",
|
||||||
|
|
|
@ -10,7 +10,7 @@ exports.config = {
|
||||||
allScriptsTimeout: 11000,
|
allScriptsTimeout: 11000,
|
||||||
jasmineNodeOpts: { defaultTimeoutInterval: 1000 * 60 * 10 },
|
jasmineNodeOpts: { defaultTimeoutInterval: 1000 * 60 * 10 },
|
||||||
maxSessions: 4,
|
maxSessions: 4,
|
||||||
specs: ['./e2e/**/*.e2e-spec.ts'],
|
specs: ['test/e2e/**/*.e2e-spec.ts'],
|
||||||
// Available deviceNames for mobileEmulation: https://chromium.googlesource.com/chromium/src/+/master/third_party/WebKit/Source/devtools/front_end/emulated_devices/module.json
|
// Available deviceNames for mobileEmulation: https://chromium.googlesource.com/chromium/src/+/master/third_party/WebKit/Source/devtools/front_end/emulated_devices/module.json
|
||||||
multiCapabilities: [
|
multiCapabilities: [
|
||||||
{
|
{
|
||||||
|
@ -104,7 +104,7 @@ exports.config = {
|
||||||
},
|
},
|
||||||
onPrepare() {
|
onPrepare() {
|
||||||
require('ts-node').register({
|
require('ts-node').register({
|
||||||
project: 'e2e/tsconfig.e2e.json'
|
project: 'test/e2e/tsconfig.e2e.json'
|
||||||
});
|
});
|
||||||
var jasmineReporters = require('jasmine-reporters');
|
var jasmineReporters = require('jasmine-reporters');
|
||||||
jasmine.getEnv().addReporter(
|
jasmine.getEnv().addReporter(
|
||||||
|
|
22
src/test.ts
|
@ -1,14 +1,16 @@
|
||||||
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
||||||
|
|
||||||
|
// tslint:disable:ordered-imports
|
||||||
import 'zone.js/dist/long-stack-trace-zone';
|
import 'zone.js/dist/long-stack-trace-zone';
|
||||||
import 'zone.js/dist/proxy.js';
|
import 'zone.js/dist/proxy.js';
|
||||||
import 'zone.js/dist/sync-test';
|
import 'zone.js/dist/sync-test';
|
||||||
import 'zone.js/dist/jasmine-patch';
|
import 'zone.js/dist/jasmine-patch';
|
||||||
import 'zone.js/dist/async-test';
|
import 'zone.js/dist/async-test';
|
||||||
import 'zone.js/dist/fake-async-test';
|
import 'zone.js/dist/fake-async-test';
|
||||||
|
// tslint:enable:ordered-imports
|
||||||
|
|
||||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
||||||
import { getTestBed, TestBed } from '@angular/core/testing';
|
import { getTestBed, TestBed } from '@angular/core/testing';
|
||||||
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
import {
|
import {
|
||||||
BrowserDynamicTestingModule,
|
BrowserDynamicTestingModule,
|
||||||
platformBrowserDynamicTesting
|
platformBrowserDynamicTesting
|
||||||
|
@ -18,10 +20,10 @@ import {
|
||||||
App,
|
App,
|
||||||
Config,
|
Config,
|
||||||
DeepLinker,
|
DeepLinker,
|
||||||
|
DomController,
|
||||||
Form,
|
Form,
|
||||||
IonicModule,
|
IonicModule,
|
||||||
Keyboard,
|
Keyboard,
|
||||||
DomController,
|
|
||||||
MenuController,
|
MenuController,
|
||||||
NavController,
|
NavController,
|
||||||
Platform
|
Platform
|
||||||
|
@ -42,24 +44,23 @@ context.keys().map(context);
|
||||||
|
|
||||||
export class TestUtils {
|
export class TestUtils {
|
||||||
public static beforeEachCompiler(
|
public static beforeEachCompiler(
|
||||||
components: Array<any>
|
components: any[]
|
||||||
): Promise<{ fixture: any; instance: any }> {
|
): Promise<{ fixture: any; instance: any }> {
|
||||||
return TestUtils.configureIonicTestingModule(components)
|
return TestUtils.configureIonicTestingModule(components)
|
||||||
.compileComponents()
|
.compileComponents()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
let fixture: any = TestBed.createComponent(components[0]);
|
const fixture: any = TestBed.createComponent(components[0]);
|
||||||
return {
|
return {
|
||||||
fixture: fixture,
|
fixture,
|
||||||
instance: fixture.debugElement.componentInstance
|
instance: fixture.debugElement.componentInstance
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static configureIonicTestingModule(
|
public static configureIonicTestingModule(components: any[]): typeof TestBed {
|
||||||
components: Array<any>
|
|
||||||
): typeof TestBed {
|
|
||||||
return TestBed.configureTestingModule({
|
return TestBed.configureTestingModule({
|
||||||
declarations: [...components],
|
declarations: [...components],
|
||||||
|
imports: [FormsModule, IonicModule, ReactiveFormsModule, TranslateModule],
|
||||||
providers: [
|
providers: [
|
||||||
App,
|
App,
|
||||||
Form,
|
Form,
|
||||||
|
@ -70,8 +71,7 @@ export class TestUtils {
|
||||||
{ provide: Platform, useFactory: () => PlatformMock.instance() },
|
{ provide: Platform, useFactory: () => PlatformMock.instance() },
|
||||||
{ provide: Config, useFactory: () => ConfigMock.instance() },
|
{ provide: Config, useFactory: () => ConfigMock.instance() },
|
||||||
{ provide: DeepLinker, useFactory: () => ConfigMock.instance() }
|
{ provide: DeepLinker, useFactory: () => ConfigMock.instance() }
|
||||||
],
|
]
|
||||||
imports: [FormsModule, IonicModule, ReactiveFormsModule, TranslateModule]
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ export class TestUtils {
|
||||||
if (el.fireEvent) {
|
if (el.fireEvent) {
|
||||||
el.fireEvent('on' + etype);
|
el.fireEvent('on' + etype);
|
||||||
} else {
|
} else {
|
||||||
let evObj: any = document.createEvent('Events');
|
const evObj: any = document.createEvent('Events');
|
||||||
evObj.initEvent(etype, true, false);
|
evObj.initEvent(etype, true, false);
|
||||||
el.dispatchEvent(evObj);
|
el.dispatchEvent(evObj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,12 @@
|
||||||
{
|
{
|
||||||
"extends": "../tsconfig.ng-cli.json",
|
"extends": "../test/tsconfig.ng-cli.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "../out-tsc/spec",
|
"outDir": "../out-tsc/spec",
|
||||||
"baseUrl": "./",
|
"baseUrl": "./",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"types": [
|
"types": ["jasmine", "node"]
|
||||||
"jasmine",
|
|
||||||
"node"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"files": [
|
"files": ["test.ts"],
|
||||||
"test.ts"
|
"include": ["**/*.spec.ts", "**/*.d.ts"]
|
||||||
],
|
|
||||||
"include": [
|
|
||||||
"**/*.spec.ts",
|
|
||||||
"**/*.d.ts"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import * as mkdirp from 'mkdirp';
|
||||||
|
|
||||||
const distribution: string = JSON.parse(
|
const distribution: string = JSON.parse(
|
||||||
readFileSync('src/assets/appConfig.json', 'utf8')
|
readFileSync('src/assets/appConfig.json', 'utf8')
|
||||||
)['packageName'];
|
).packageName;
|
||||||
|
|
||||||
const dir = join('test', 'latest', distribution);
|
const dir = join('test', 'visual', 'latest', distribution);
|
||||||
// create dir if it doesn't exist
|
// create dir if it doesn't exist
|
||||||
mkdirp(dir);
|
mkdirp(dir);
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ document.body.appendChild(elem);
|
||||||
export async function takeScreenshot(name: string) {
|
export async function takeScreenshot(name: string) {
|
||||||
browser.executeScript(jsToInjectCSSHack);
|
browser.executeScript(jsToInjectCSSHack);
|
||||||
const config = await browser.getProcessedConfig();
|
const config = await browser.getProcessedConfig();
|
||||||
const deviceName = config['capabilities']['name'];
|
const deviceName = config['capabilities'].name;
|
||||||
const pngData = await browser.takeScreenshot();
|
const pngData = await browser.takeScreenshot();
|
||||||
const path = join(dir, `${name}_${deviceName}.png`);
|
const path = join(dir, `${name}_${deviceName}.png`);
|
||||||
writeFile(path, pngData, { encoding: 'base64' }, err => {
|
writeFile(path, pngData, { encoding: 'base64' }, err => {
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
module.exports = function(config) {
|
module.exports = function(config) {
|
||||||
config.set({
|
config.set({
|
||||||
basePath: '',
|
basePath: '..',
|
||||||
frameworks: ['jasmine', '@angular/cli'],
|
frameworks: ['jasmine', '@angular/cli'],
|
||||||
plugins: [
|
plugins: [
|
||||||
require('karma-jasmine'),
|
require('karma-jasmine'),
|
|
@ -1,14 +1,14 @@
|
||||||
{
|
{
|
||||||
"compileOnSave": false,
|
"compileOnSave": false,
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "./dist/out-tsc",
|
"outDir": "../dist/out-tsc",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"declaration": false,
|
"declaration": false,
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"typeRoots": ["node_modules/@types"],
|
"typeRoots": ["../node_modules/@types"],
|
||||||
"lib": ["es2017", "dom"]
|
"lib": ["es2017", "dom"]
|
||||||
}
|
}
|
||||||
}
|
}
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 57 KiB |
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 53 KiB |
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 82 KiB |
Before Width: | Height: | Size: 67 KiB After Width: | Height: | Size: 67 KiB |
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 60 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 79 KiB |
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||||
"rules": {
|
"rules": {
|
||||||
"interface-name": [true, "never-prefix"]
|
"interface-name": [true, "never-prefix"],
|
||||||
|
"no-submodule-imports": [true, "zone.js", "@angular"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|