Skip to content

Commit

Permalink
build(devs-infra): add example app Angular v12 (#924)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnpnl committed May 17, 2021
1 parent 96782a6 commit f4e814e
Show file tree
Hide file tree
Showing 34 changed files with 17,392 additions and 19 deletions.
5 changes: 4 additions & 1 deletion examples/example-app-v10/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,8 @@
}
}
},
"defaultProject": "example-app-v10"
"defaultProject": "example-app-v10",
"cli": {
"packageManager": "npm"
}
}
5 changes: 4 additions & 1 deletion examples/example-app-v11/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,8 @@
}
}
},
"defaultProject": "example-app-v11"
"defaultProject": "example-app-v11",
"cli": {
"packageManager": "npm"
}
}
17 changes: 17 additions & 0 deletions examples/example-app-v12/.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 versions
last 2 iOS major versions
Firefox ESR
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
16 changes: 16 additions & 0 deletions examples/example-app-v12/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.ts]
quote_type = single

[*.md]
max_line_length = off
trim_trailing_whitespace = false
46 changes: 46 additions & 0 deletions examples/example-app-v12/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp
/out-tsc
# Only exists if Bazel was run
/bazel-out

# dependencies
/node_modules

# profiling files
chrome-profiler-events*.json
speed-measure-plugin*.json

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db
31 changes: 31 additions & 0 deletions examples/example-app-v12/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Example

This is an example app using `jest-preset-angular`. It is not supposed to be a boilerplate for an Angular app tested with jest, but could be used as a rough reference for configuration.

The jest configuration itself is located in the `jest.config.js`.

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 12.0.0.

## Running unit tests

Run `yarn test` or `npm test` to execute the unit tests via [Jest](https://jestjs.io).

## Running end-to-end tests

End-to-end are not setup in this project.

## Development server

Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.

## Code scaffolding

Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.

## Build

Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.

## Further help

To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
94 changes: 94 additions & 0 deletions examples/example-app-v12/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"example-app-v12": {
"projectType": "application",
"schematics": {
"@schematics/angular:application": {
"strict": true
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/example-app-v12",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css"
],
"scripts": [],
"vendorChunk": true,
"extractLicenses": false,
"buildOptimizer": false,
"sourceMap": true,
"optimization": false,
"namedChunks": true
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "example-app-v12:build"
},
"configurations": {
"production": {
"browserTarget": "example-app-v12:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "example-app-v12:build"
}
}
}
}
},
"defaultProject": "example-app-v12",
"cli": {
"packageManager": "npm"
}
}
13 changes: 13 additions & 0 deletions examples/example-app-v12/jest-esm.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require('jest-preset-angular/ngcc-jest-processor');

/** @type {import('@jest/types').Config.InitialOptions} */
module.exports = {
preset: 'jest-preset-angular/presets/defaults-esm',
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig-esm.spec.json',
stringifyContentPathRegex: '\\.html$',
},
},
setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'],
};
24 changes: 24 additions & 0 deletions examples/example-app-v12/jest-global-mocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Object.defineProperty(window, 'CSS', { value: null });
Object.defineProperty(document, 'doctype', {
value: '<!DOCTYPE html>',
});
Object.defineProperty(window, 'getComputedStyle', {
value: () => {
return {
display: 'none',
appearance: ['-webkit-appearance'],
};
},
});
/**
* ISSUE: https://github.com/angular/material2/issues/7101
* Workaround for JSDOM missing transform property
*/
Object.defineProperty(document.body.style, 'transform', {
value: () => {
return {
enumerable: true,
configurable: true,
};
},
});
7 changes: 7 additions & 0 deletions examples/example-app-v12/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require('jest-preset-angular/ngcc-jest-processor');

/** @type {import('@jest/types').Config.InitialOptions} */
module.exports = {
preset: 'jest-preset-angular',
setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'],
};

0 comments on commit f4e814e

Please sign in to comment.