samedi 29 juillet 2017

drive Karma tests with modules and inheritance

I have set up my project stack with Rollup, Babel and Gulp to code with ES2015 + stage-2

I have several modules exposing some default classes and I want using inheritance (extends)

It compiles OK, but The problem comes with tests : using Karma and Jasmine... How to tell the test runner to include to parent, the super-parent of a given class ?

Everything falls with the message

TypeError: Super expression must either be null or a function, not undefined

this means that parent classes are not loaded by the test runner...

// src/A.js
export default class A {}

// src/B.js
import A from  './A'

export class B extends A {} 

karma.config.js snippet :

 files: [
   'src/**/*.js',
   'test/**/*.js'
 ],

preprocessors: {
  'src/**/*.js': ['babel'],
  'test/**/*.js': ['babel']
},

babelPreprocessor: {
  options: {
  // babelrc: false,
    presets: ['es2015', 'stage-2'],
    sourceMap: 'inline',
    plugins: [
      ["transform-class-properties", { "spec": true }],
      ["transform-es2015-modules-umd"]
    ]
  }   

How to solve this case ?

Aucun commentaire:

Enregistrer un commentaire