This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
pre() { | |
}, | |
// This hook is used to manipulate the webpack configuration | |
config(cfg) { | |
return cfg; | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = ` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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: [ | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"include": [ | |
"integration/*.ts", | |
"../node_modules/cypress" | |
], | |
"compilerOptions": { | |
"emitDecoratorMetadata": true, | |
"experimentalDecorators": true, | |
"skipLibCheck": true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
..... | |
"scripts": { | |
... | |
"cy:open": "cypress open", | |
"cy:run": "cypress run" | |
}, | |
.... | |
} |