Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: Cannot read property 'stats' of undefined #198

Closed
TrySound opened this issue Nov 12, 2015 · 3 comments
Closed

cli: Cannot read property 'stats' of undefined #198

TrySound opened this issue Nov 12, 2015 · 3 comments
Labels
bug current functionality does not work as desired

Comments

@TrySound
Copy link
Contributor

Hi got this error

  √ should load from memory
TypeError: Cannot read property 'stats' of undefined
    at C:\Users\Frontend\AppData\Roaming\nvm\v0.12.5\node_modules\ava\cli.js:139:16
    at Array.map (native)
    at exit (C:\Users\Frontend\AppData\Roaming\nvm\v0.12.5\node_modules\ava\cli.js:138:22)
From previous event:
    at Object.<anonymous> (C:\Users\Frontend\AppData\Roaming\nvm\v0.12.5\node_modules\ava\cli.js:216:18)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

Here's my code

import test from 'ava';
import { rollup } from 'rollup';

process.chdir(__dirname);

test('should load from memory', t => {
    return rollup({
        entry: '../src/index.js',
        plugins: []
    }).then(bundle => {
        var result = bundle.generate({
            format: 'cjs'
        });

        console.log(result.code);
    });
});

When I remove console.log, error does not reject. It doesn't seem problem in rollup.

@sindresorhus
Copy link
Member

Thanks for report. We'll look into it.

process.chdir(__dirname);

You don't need this. AVA does this for you.

And btw, you should take advantage of async functions ;)

import test from 'ava';
import { rollup } from 'rollup';

test('should load from memory', async t => {
    const bundle = await rollup({
        entry: '../src/index.js',
        plugins: []
    });

    const result = bundle.generate({
        format: 'cjs'
    });

    console.log(result.code);
});

@sindresorhus sindresorhus added the bug current functionality does not work as desired label Nov 12, 2015
@TrySound
Copy link
Contributor Author

@sindresorhus Oh cool about chdir. I'm just afraid a little new syntax :)) But will try. Still babel is out of the box :)

@GabiGrin
Copy link

I got this error too.
In my case, I saw that it was caused by padding ava an empty .js file.

I was able to recreate from scratch by running ava via cli on a directory containing one file with a valid test and another empty file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug current functionality does not work as desired
Projects
None yet
Development

No branches or pull requests

3 participants