Skip to content

Commit

Permalink
feat: angular 10 support
Browse files Browse the repository at this point in the history
BREAKING CHANGE: A10

closes #148, #149
  • Loading branch information
satanTime committed Jul 2, 2020
1 parent 466d5ca commit 700b86f
Show file tree
Hide file tree
Showing 282 changed files with 68,599 additions and 391 deletions.
20 changes: 14 additions & 6 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
/coverage
/dist
/node_modules
/e2e/angular5/node_modules
/e2e/angular6/node_modules
/e2e/angular7/node_modules
/e2e/angular8/node_modules
/e2e/angular9-ivy-false/node_modules
/e2e/angular9-ivy-true/node_modules
/e2e/angular5-es5/node_modules
/e2e/angular5-es2015/node_modules
/e2e/angular6-es5/node_modules
/e2e/angular6-es2015/node_modules
/e2e/angular7-es5/node_modules
/e2e/angular7-es2015/node_modules
/e2e/angular8-es5/node_modules
/e2e/angular8-es2015/node_modules
/e2e/angular9-es5-ivy-false/node_modules
/e2e/angular9-es2015-ivy-false/node_modules
/e2e/angular9-es5-ivy-true/node_modules
/e2e/angular9-es2015-ivy-true/node_modules
/e2e/angular10-es2015-ivy-false/node_modules
/e2e/angular10-es2015-ivy-true/node_modules
52 changes: 40 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,45 @@ git:
autocrlf: false
install:
- npm install
script:
- npm run test:angular-versions
jobs:
include:
- name: 'Unit Tests'
script:
- npm run test:angular-versions
cache:
directories:
- $HOME/.npm
- $HOME/.node-gyp
- node_modules
- name: 'E2E A5 ES5'
script:
- npm run install
- npm run build
- npm run i:a5es5
- npm run s:a5es5
- npm run s:test:a5es5
- npm run test:a5es5
- npm run clear:a5es5
cache:
directories:
- $HOME/.npm
- $HOME/.node-gyp
- node_modules
- e2e/angular5-es5/node_modules
- name: 'E2E A5 ES2015'
script:
- npm run install
- npm run build
- npm run i:a5es2015
- npm run s:a5es2015
- npm run s:test:a5es2015
- npm run test:a5es2015
- npm run clear:a5es2015
cache:
directories:
- $HOME/.npm
- $HOME/.node-gyp
- node_modules
- e2e/angular5-es2015/node_modules
cache:
npm: false
directories:
- $HOME/.npm
- $HOME/.node-gyp
- node_modules
- e2e/angular5/node_modules
- e2e/angular6/node_modules
- e2e/angular7/node_modules
- e2e/angular8/node_modules
- e2e/angular9-ivy-false/node_modules
- e2e/angular9-ivy-true/node_modules
20 changes: 14 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@ CMD ["sh", "build-with-supported-angluars.sh"]

VOLUME /npm
VOLUME /app/node_modules
VOLUME /app/e2e/angular5/node_modules
VOLUME /app/e2e/angular6/node_modules
VOLUME /app/e2e/angular7/node_modules
VOLUME /app/e2e/angular8/node_modules
VOLUME /app/e2e/angular9-ivy-false/node_modules
VOLUME /app/e2e/angular9-ivy-true/node_modules
VOLUME /app/e2e/angular5-es5/node_modules
VOLUME /app/e2e/angular5-es2015/node_modules
VOLUME /app/e2e/angular6-es5/node_modules
VOLUME /app/e2e/angular6-es2015/node_modules
VOLUME /app/e2e/angular7-es5/node_modules
VOLUME /app/e2e/angular7-es2015/node_modules
VOLUME /app/e2e/angular8-es5/node_modules
VOLUME /app/e2e/angular8-es2015/node_modules
VOLUME /app/e2e/angular9-es5-ivy-false/node_modules
VOLUME /app/e2e/angular9-es2015-ivy-false/node_modules
VOLUME /app/e2e/angular9-es5-ivy-true/node_modules
VOLUME /app/e2e/angular9-es2015-ivy-true/node_modules
VOLUME /app/e2e/angular10-es2015-ivy-false/node_modules
VOLUME /app/e2e/angular10-es2015-ivy-true/node_modules

RUN npm config set cache /npm --global

Expand Down
33 changes: 26 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ Helper function for creating angular mocks for test.

Tested on:

- Angular 5 (Jasmine, Jest)
- Angular 6 (Jasmine, Jest)
- Angular 7 (Jasmine, Jest)
- Angular 8 (Jasmine, Jest)
- Angular 9 (Jasmine, Jest, Ivy)
- Angular 5 (Jasmine, Jest, es5, es2015)
- Angular 6 (Jasmine, Jest, es5, es2015)
- Angular 7 (Jasmine, Jest, es5, es2015)
- Angular 8 (Jasmine, Jest, es5, es2015)
- Angular 9 (Jasmine, Jest, Ivy, es5, es2015)
- Angular 10 (Jasmine, Jest, Ivy, es2015)

## Why use this?

Expand Down Expand Up @@ -147,6 +148,8 @@ Our tests:
- [Structural Components](#usage-example-of-structural-directives)
- [Auto Spy](#auto-spy)

* [Troubleshooting](#troubleshooting)

---

## MockComponent(s)
Expand Down Expand Up @@ -548,9 +551,9 @@ import { MyModule } from './fixtures.modules';
describe('MockBuilder:simple', () => {
beforeEach(() => MockBuilder(MyComponent, MyModule));
// the same as
// beforeEach(() => TestBed.configureTestingModule({{
// TestBed.configureTestingModule({{
// imports: [MockModule(MyModule)], // but MyComponent wasn't mocked for the testing purposes.
// }).compileComponents());
// }).compileComponents();
// and we can simply pass it to the TestBed.

it('should render content ignoring all dependencies', () => {
Expand Down Expand Up @@ -803,6 +806,10 @@ describe('MockRender', () => {

ngMocks provides functions to get attribute and structural directives from an element, find components and mock objects.

- ngMocks.mockedComponent(instance)
- ngMocks.mockedDirective(instance)
- ngMocks.mockedPipe(instance)

- ngMocks.get(debugElement, directive, notFoundValue?)
- ngMocks.findInstance(debugElement, directive, notFoundValue?)
- ngMocks.findInstances(debugElement, directive)
Expand Down Expand Up @@ -942,6 +949,18 @@ import 'ng-mocks/dist/jest';

---

## Troubleshooting

### Angular 10 throws "TS2339: Property '\*' does not exist on type ..."

Instead of using `instance.__*` the `instance` should be wrapped by:

- `ngMocks.mockedComponent(instance).__*`
- `ngMocks.mockedDirective(instance).__*`
- `ngMocks.mockedPipe(instance).__*`

---

## Find an issue or have a request?

Report it as an issue or submit a PR. I'm open to contributions.
Expand Down
14 changes: 7 additions & 7 deletions build-with-supported-angluars.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
set -e
VERSIONS="5 6 7 8 9"
VERSIONS="5 6 7 8 9 10"
PACKAGES="animations common compiler core forms platform-browser platform-browser-dynamic router"

for version in $VERSIONS
Expand All @@ -14,11 +14,12 @@ do
NEW="$NEW @angular/$package@$version"
done

echo $version | grep -Eq "^5" && NEW="$NEW rxjs@5.5.5 zone.js@0.8.14 typescript@2.4"
echo $version | grep -Eq "^6" && NEW="$NEW rxjs@6.0.0 zone.js@0.8.26 typescript@2.7"
echo $version | grep -Eq "^7" && NEW="$NEW rxjs@6.0.0 zone.js@0.8.26 typescript@3.1"
echo $version | grep -Eq "^8" && NEW="$NEW rxjs@6.4.0 zone.js@0.9.1 typescript@3.4.3"
echo $version | grep -Eq "^9" && NEW="$NEW rxjs@6.5.3 zone.js@0.10.2 typescript@3.6.4"
echo $version | grep -Eq "^5$" && NEW="$NEW rxjs@5.5.5 zone.js@0.8.14 typescript@2.4"
echo $version | grep -Eq "^6$" && NEW="$NEW rxjs@6.0.0 zone.js@0.8.26 typescript@2.7"
echo $version | grep -Eq "^7$" && NEW="$NEW rxjs@6.0.0 zone.js@0.8.26 typescript@3.1"
echo $version | grep -Eq "^8$" && NEW="$NEW rxjs@6.4.0 zone.js@0.9.1 typescript@3.4.3"
echo $version | grep -Eq "^9$" && NEW="$NEW rxjs@6.5.3 zone.js@0.10.2 typescript@3.6.4"
echo $version | grep -Eq "^10$" && NEW="$NEW rxjs@6.5.5 zone.js@0.10.3 typescript@3.9.5"

echo $NEW

Expand All @@ -27,5 +28,4 @@ do
npm run build:all
done
npm install --silent --quiet --no-progress
npm run e2e
echo Testing complete
17 changes: 17 additions & 0 deletions e2e/angular10-es2015-ivy-false/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries

# For the full list of supported browsers by the Angular framework, please see:
# https://angular.io/guide/browser-support

# You can see what browsers were selected by your queries by running:
# npx browserslist

last 1 Chrome version
last 1 Firefox version
last 2 Edge major versions
last 2 Safari major version
last 2 iOS major versions
Firefox ESR
not IE 9-11 # For IE 9-11 support, remove 'not'.
File renamed without changes.
File renamed without changes.
101 changes: 101 additions & 0 deletions e2e/angular10-es2015-ivy-false/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"a10es2015f": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/a10es2015f",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": ["src/favicon.ico", "src/assets"],
"styles": ["src/styles.scss"],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "a10es2015f:build"
},
"configurations": {
"production": {
"browserTarget": "a10es2015f:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "a10es2015f:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"assets": ["src/favicon.ico", "src/assets"],
"styles": ["src/styles.scss"],
"scripts": []
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["tsconfig.app.json", "tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
}
}
}
}
},
"defaultProject": "a10es2015f"
}
40 changes: 40 additions & 0 deletions e2e/angular10-es2015-ivy-false/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

process.env.CHROME_BIN = require('puppeteer').executablePath();

module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('@angular-devkit/build-angular/plugins/karma'),
require('karma-chrome-launcher'),
require('karma-coverage-istanbul-reporter'),
require('karma-ie-launcher'),
require('karma-jasmine'),
require('karma-jasmine-html-reporter'),
],
client: {
clearContext: false, // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, './coverage/app'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true,
},
customLaunchers: {
ChromeCi: {
base: 'ChromeHeadless',
flags: ['--headless', '--disable-gpu', '--no-sandbox', '--disable-dev-shm-usage'],
},
},
reporters: ['kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: ['ChromeCi'],
singleRun: true,
});
};
Loading

0 comments on commit 700b86f

Please sign in to comment.