Nerajno / gulp-jest

Gulp plugin for the Jest test lib
MIT License
53 stars 43 forks source link

Doesn't work in the node environment #50

Closed xfg closed 3 years ago

xfg commented 6 years ago

I am trying to use this plugin in node.js environment but get error

(node:25310) UnhandledPromiseRejectionWarning: ReferenceError: describe is not defined
    at Object.<anonymous> (/home/user/project/tests/MyFirstTest.spec.js:7:1)

gulpfile

const gulp = require('gulp');
const jest = require('gulp-jest');

const paths = {
  specs: {
    src: ['tests/MyFirstTest.spec.js']
  }
};

gulp.task('test', () => {
  return gulp.src(paths.specs.src)
    .pipe(jest.default({testEnvironment: 'node'}));
});

When I use jest directly then all work as expected. What am I doing wrong?

TheDancingCode commented 6 years ago

Did you install the jest-cli locally?

xfg commented 6 years ago

Yes, I installed jest-cli locally as the readme recommended.

TheDancingCode commented 6 years ago

It seems to work when you pass the directory where your test lives instead of the path of the testfile itself:

const paths = {
  specs: {
    src: ['tests/']
  }
};
alansouzati commented 6 years ago

does it work if you remove testEnvironment ?

aarontrank commented 3 years ago

please reopen if issue still persists.