mardi 23 février 2016

Jasmine complains about imported css in unit tests

I'm trying to run some unit tests on a javascript module I wrote.

The test is simple:

import {FornaContainer} from '../app/scripts/fornac.js';

describe('A forna container', function() {
    it('should accept a colorscheme', function() {


    });
});

The problem is that in ../app/scripts/fornac.js I import a css file:

import '../styles/fornac.css';

This causes jasmine to produce the following error:

events.js:72
        throw er; // Unhandled 'error' event
              ^
SyntaxError: /home/mescalin/pkerp/projects/fornac/app/styles/fornac.css: Unexpected token (1:4)
> 1 | svg {
    |     ^
  2 |   display: block;
  3 |   min-width: 100%;
  4 |   width: 100%;
    at Parser.pp.raise (/home/mescalin/pkerp/projects/fornac/node_modules/babel-core/node_modules/babylon/index.js:1425:13)
    at Parser.pp.unexpected (/home/mescalin/pkerp/projects/fornac/node_modules/babel-core/node_modules/babylon/index.js:2907:8)
    at Parser.pp.semicolon (/home/mescalin/pkerp/projects/fornac/node_modules/babel-core/node_modules/babylon/index.js:2894:38)
    at Parser.pp.parseExpressionStatement (/home/mescalin/pkerp/projects/fornac/node_modules/babel-core/node_modules/babylon/index.js:2264:8)
    at Parser.pp.parseStatement (/home/mescalin/pkerp/projects/fornac/node_modules/babel-core/node_modules/babylon/index.js:1955:17)
    at Parser.pp.parseBlockBody (/home/mescalin/pkerp/projects/fornac/node_modules/babel-core/node_modules/babylon/index.js:2294:21)
    at Parser.pp.parseTopLevel (/home/mescalin/pkerp/projects/fornac/node_modules/babel-core/node_modules/babylon/index.js:1823:8)
    at Parser.parse (/home/mescalin/pkerp/projects/fornac/node_modules/babel-core/node_modules/babylon/index.js:1396:17)
    at Object.parse (/home/mescalin/pkerp/projects/fornac/node_modules/babel-core/node_modules/babylon/index.js:45:50)
    at File.parse (/home/mescalin/pkerp/projects/fornac/node_modules/babel-core/lib/transformation/file/index.js:480:24)

Removing the import ../styles/fornac.css line in fornac.js removes the error.

Any ideas for how to test my javascript file without getting errors about the css import?

Aucun commentaire:

Enregistrer un commentaire