karma-ava icon indicating copy to clipboard operation
karma-ava copied to clipboard

Don't support babel to convert es6 ?

Open dwqs opened this issue 8 years ago • 2 comments

Some versions

Node version : v8.1.3 Karma-ava : v0.0.1 ava: github:jamestalmage/ava#karma-ava

Karma config

The config as follows:

let path = require('path');

module.exports = config => {
    config.set({
        frameworks: ['ava'],
        basePath: '',
        files: [
            './demo/ava.spec.js'
        ],
        browsers: ['Chrome'],
        plugins: [
            'karma-chrome-launcher',
            'karma-ava',
            'karma-sourcemap-loader',
            'karma-webpack',
            'karma-mocha-reporter'
        ],
        reporters: ['progress', 'mocha'],
        singleRun: true,
        autoRun: true,
        mochaReporter: {
            colors: {
                success: 'blue',
                info: 'bgGreen',
                warning: 'cyan',
                error: 'bgRed'
            },
            symbols: {
                success: '+',
                info: '#',
                warning: '!',
                error: 'x'
            }
        },
        preprocessors: {
            './demo/ava.spec.js': ['webpack', 'sourcemap'],
            './src/**/*.js': ['webpack', 'sourcemap']
        },
        logLevel: config.LOG_INFO,
        colors: true,
        webpack: {
            devtool: 'inline-source-map',
            module: {
                rules: [
                    {
                        test: /\.js$/,
                        exclude: /node_modules/,
                        include: [
                            path.resolve(__dirname, 'src')
                        ],
                        use: [{
                            loader: 'babel-loader',
                            options: {
                                presets: ['es2015']
                            }
                        }]
                    }
                ]
            },
            resolve: {
                extensions: ['.js'],
                modules: [path.join(__dirname, './node_modules')]
            }
        },
        webpackMiddleware: {
            noInfo: true
        }
    });
};

My directory hierarchy as follows:

-test
   -demo
        -ava.spec.js
   -src
        -css.js
        -helper.js
   -karma.config.ava.js

When run ./node_modules/.bin/karma start karma.conf.ava.js in terminal, I got some error as follows:

START:
06 08 2017 16:53:01.450:INFO [karma]: Karma v1.7.0 server started at http://0.0.0.0:9876/
06 08 2017 16:53:01.452:INFO [launcher]: Launching browser Chrome with unlimited concurrency
Unhandled rejection
/Users/pomy/git/test/src/css.js:1
import { ownerDocument, checkToken } from './helper';
^
ParseError: 'import' and 'export' may appear only with 'sourceType: module'
06 08 2017 16:53:01.459:INFO [launcher]: Starting browser Chrome
06 08 2017 16:53:02.195:INFO [Chrome 59.0.3071 (Mac OS X 10.12.6)]: Connected on socket 2WXI-frxz-uhsFR0AAAA with id 37621167
Chrome 59.0.3071 (Mac OS X 10.12.6) ERROR
  You need to include some adapter that implements __karma__.start method!

Chrome 59.0.3071 (Mac OS X 10.12.6) ERROR
  You need to include some adapter that implements __karma__.start method!

ava.spec.js:

import test from 'ava';

import css from '../src/css';

// console.log('66666', typeof css);

test('foo', t => {
    // console.log(typeof css);
    t.is(1, 1);
});

css.js:

import { ownerDocument, checkToken } from './helper';

export default function css () { .... }

helper.js

export const ownerDocument =  function ownerDocument () { .... }
export const checkToken =  function checkToken () { .... }

dwqs avatar Aug 06 '17 09:08 dwqs

Hey @dwqs. Looks like something isn't transpiling module syntax.

I'm not sure this module would be a good fit for you though. It hasn't been worked on for over a year, for one. Personally I'm not familiar enough with the various pieces in your setup to help figure out where the transpilation is lacking, either.

novemberborn avatar Aug 06 '17 14:08 novemberborn

Thanks for your response. Maybe someone who sees this issue has a good idea for my problem.

dwqs avatar Aug 06 '17 16:08 dwqs