mkurnikov
mkurnikov

Reputation: 1701

Jasmine + Webpack: vendor jasmine global functions

I'm using Karma+Jasmine to test my webpack-based angular2 app.

To build project on development, I'm using vendor.ts for angular dependencies to keep main file as small as possible, and reduce webpack recompile time.

// Angular
import '@angular/platform-browser';
import '@angular/platform-browser-dynamic';
import '@angular/core';
import '@angular/common';
import '@angular/http';
import '@angular/router';
import '@angular/forms';

// RxJS
import 'rxjs';

import 'zone.js';
import 'reflect-metadata';

I've created test.ts in which I import all my tests. I recompile it every time before karma start.

The problem is that final test.js contains not only tests code, but the whole jasmine library. I want to vendor it too, but couldn't find right vendor import.

Looks like Jasmine is global library by default, and I haven't been able to find any @types/jasmine-core in dt.

Could anyone help me with that?

Upvotes: 0

Views: 155

Answers (1)

mkurnikov
mkurnikov

Reputation: 1701

Ok, it seems that I was wrong in perceiving Jasmine as something I need to vendor. Functions like describe and it will be available on test run anyway, whether or not they will be present in the compiled files.

The only thing I needed to vendor in my case was expect, and I've achieved that through adding

import * as expect from "expect";
expect('true').toBe('true'); //doesn't work without it, for some reason

in the vendor file.

Upvotes: 0

Related Questions