Skip to content

Instantly share code, notes, and snippets.

David meDavid

Block or report user

Report or block meDavid

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View empty-ngx-build-plus-plugin.ts
export default {
pre() {
},
// This hook is used to manipulate the webpack configuration
config(cfg) {
return cfg;
},
@meDavid
meDavid / ng-ts-dummy-transformer.ts
Created Mar 18, 2019
A dummy Typescript transformer that logs the filenames to the console
View ng-ts-dummy-transformer.ts
import * as ts from 'typescript';
export const dummyTransformer = <T extends ts.Node>(context: ts.TransformationContext) => {
return (rootNode: ts.SourceFile) => {
console.log('Transforming file: ' + rootNode.fileName);
function visit(node: ts.Node): ts.Node {
return ts.visitEachChild(node, visit, context);
}
return ts.visitNode(rootNode, visit);
};
@meDavid
meDavid / ng-ts-register-transformer.ts
Last active Mar 18, 2019
Example ngx-build-plus plugin to register a typescript transformer
View ng-ts-register-transformer.ts
import { dummyTransformer } from './ng-ts-dummy-transformer';
import { AngularCompilerPlugin } from '@ngtools/webpack';
function findAngularCompilerPlugin(webpackCfg): AngularCompilerPlugin | null {
return webpackCfg.plugins.find(plugin => plugin instanceof AngularCompilerPlugin);
}
// The AngularCompilerPlugin has nog public API to add transformations, user private API _transformers instead.
function addTransformerToAngularCompilerPlugin(acp, transformer): void {
acp._transformers = [transformer, ...acp._transformers];
@meDavid
meDavid / spec-private-api.ts
Last active Jan 14, 2019
cypress angular unittest with private APIs
View spec-private-api.ts
import { ɵrenderComponent as renderComponent, ɵcompileComponent as compileComponent} from '@angular/core';
import '@angular/compiler';
import 'zone.js';
import { AppComponent } from '../../src/app/app.component';
/* eslint-env mocha */
/* global cy */
describe('AppComponent', () => {
beforeEach(() => {
const html = `
View cy-ts-preprocessor.js
// Copy of https://github.com/bahmutov/cypress-angular-unit-test/blob/master/cypress/plugins/cy-ts-preprocessor.js
const wp = require('@cypress/webpack-preprocessor')
const webpackOptions = {
resolve: {
extensions: ['.ts', '.js']
},
module: {
rules: [
{
@meDavid
meDavid / tsconfig.json
Created Jan 11, 2019
Minimal Cypress tsconfig file
View tsconfig.json
{
"include": [
"integration/*.ts",
"../node_modules/cypress"
],
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"skipLibCheck": true
}
@meDavid
meDavid / package.json
Created Jan 11, 2019
Cypress package.json scripts
View package.json
{
.....
"scripts": {
...
"cy:open": "cypress open",
"cy:run": "cypress run"
},
....
}
You can’t perform that action at this time.