Skip to content

Instantly share code, notes, and snippets.

@tiberiucorbu
Last active January 25, 2017 23:48
Show Gist options
  • Save tiberiucorbu/fb9acd2f286e3452ef06df9d6bae9210 to your computer and use it in GitHub Desktop.
Save tiberiucorbu/fb9acd2f286e3452ef06df9d6bae9210 to your computer and use it in GitHub Desktop.
dist
node_modules/

Sample application that describes the configuration problem.

Run npm install to get the dependencies and npm test to run the index.spec.ts test.

Currently it fails with :

25 01 2017 20:02:04.734:INFO [karma]: Karma v1.3.0 server started at http://localhost:9876/
25 01 2017 20:02:04.736:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
25 01 2017 20:02:04.740:INFO [launcher]: Starting browser PhantomJS
25 01 2017 20:02:06.304:INFO [PhantomJS 2.1.1 (Windows 7 0.0.0)]: Connected on socket /#-FVT7ItY2HRYNXnOAAAA with id 56600517
PhantomJS 2.1.1 (Windows 7 0.0.0) Application extend should use Object.assign FAILED
        Failed: undefined is not a constructor (evaluating 'Object.assign(a, b)')
        extend@index.spec.ts:81:30
        index.spec.ts:59:44
        loaded@http://localhost:9876/context.js:151:17
PhantomJS 2.1.1 (Windows 7 0.0.0): Executed 1 of 1 (1 FAILED) ERROR (0.002 secs / 0.001 secs)
npm ERR! Test failed.  See above for more details.
import {Application} from './index';
describe('Application', () => {
let underTest: Application;
beforeEach(() => {
underTest = new Application();
});
describe('extend', () => {
it('should use Object.assign', () => {
try {
let any = underTest.extend({a: 1}, {b: 2});
expect(any.a).toBe(1);
expect(any.b).toBe(2);
} catch (e) {
fail(e);
}
});
});
});
export class Application {
public extend (a, b) : any{
return Object.assign(a, b);
}
}
var webpackConfig = require('./webpack.conf.js');
module.exports = function (config) {
config.set({
frameworks: ['jasmine'],
files: [
'./dist/polyfills.js',
'./**/*.spec.ts'
],
proxies: {},
exclude: [],
preprocessors: {
'./*.ts': ['webpack']
},
webpack: webpackConfig,
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['PhantomJS'],
mime: {
'text/x-typescript': ['ts','tsx']
},
singleRun: true,
concurrency: Infinity,
plugins: ['karma-phantomjs-launcher', 'karma-sourcemap-loader', 'karma-webpack', 'karma-jasmine']
})
};
{
"name": "es6-test",
"version": "1.0.0",
"description": "A project that uses es6 features with polifils",
"main": "index.ts",
"scripts": {
"test": "karma start ./karma.conf",
"build": "webpack --config ./webpack.conf"
},
"keywords": [
"es6",
"typescript",
"karma",
"core-js"
],
"devDependencies": {
"@types/jasmine": "2.5.38",
"awesome-typescript-loader": "2.2.4",
"core-js": "2.4.1",
"jasmine": "2.5.2",
"jasmine-co": "1.2.1",
"jasmine-core": "2.5.2",
"jasmine-jquery": "2.1.1",
"karma": "1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-jasmine": "^1.1.0",
"karma-phantomjs-launcher": "^1.0.2",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^1.8.0",
"typescript": "2.1.1",
"webpack": "1.13.3"
},
"author": "Tiberiu CORBU",
"license": "ISC"
}
import * as polyfills from 'core-js';
console.log(polyfills);
polyfills();
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"lib": [
"dom",
"es5",
"scripthost",
"es2015.promise",
"ES6"
],
"sourceMap": true
},
"exclude": [
"node_modules"
]
}
var webpack = require('webpack');
module.exports = {
entry: {
'app': [
'./index.ts'
],
'polyfills': [
'core-js'
]
},
output: {
path: 'dist/',
filename: '[name].js',
library: 'extint',
libraryTarget: 'var'
},
resolve: {
extensions: ['', '.ts', '.js']
},
module: {
loaders: [
{
test: /\.ts$/,
loaders: ['awesome-typescript']
}
]
},
plugins: [
// new webpack.ProvidePlugin({
// '': 'imports?this=>window!core-js/index.js'
// })
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment