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

jest.runCli returns a promise now, the callback in tasks/jest.js never gets executed #896

Closed
1hella opened this Issue Jun 26, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@1hella
Contributor

1hella commented Jun 26, 2018

I'm submitting a bug report

  • Library Version:
    0.33.1

Please tell us about your environment:

  • Operating System:
    OSX 10.13.5

  • Node Version:
    9.11.1

  • NPM Version:
    5.8.0

  • Browser:
    N/A

  • Language:
    all

  • Loader/bundler:
    all

Current behavior:

I wanted to run the jest tests automatically when running au build --env dev so I added the following to tasks/build.js:

import jest from './jest';

...

function test(done) {
  if (!production) {
    jest(done);
  } else {
    done();
  }
}

const build = gulp.series(
  clearDist,
  test,
  configureEnvironment,
  buildWebpack
);

And the build exits every time after the test phase.

  • What is the expected behavior?
    The build should continue to configureEnvironment and buildWebpack after test.

  • What is the motivation / use case for changing the behavior?
    As discovered while reading this post: facebook/jest#5048, "commit 200b032 changed the runCli() - it removed the onComplete callback and replaced it with a Promise".

Changing

jest.runCLI(options, [path.resolve(__dirname, '../../')], (result) => {
  if (result.numFailedTests || result.numFailedTestSuites) {
    cb(new gutil.PluginError('gulp-jest', { message: 'Tests Failed' }));
  } else {
    cb();
  }
});

to

 
  jest.runCLI(options, [path.resolve(__dirname, '../../')]).then((result) => {
    if (result.numFailedTests || result.numFailedTestSuites) {
      cb(new gutil.PluginError('gulp-jest', { message: 'Tests Failed' }));
    } else {
      cb();
    }
  });

fixes this issue.

1hella added a commit to 1hella/cli that referenced this issue Jun 26, 2018

fix(jest): update usage of jest.runCli
jest.runCli returns a promise. This change updates the usage of jest.runCli to use the promise rather than pass in a callback which never will get executed.

closes aurelia#896
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment