Skip to content

Is it possible to run with Jest? #41

@edouard-lopez

Description

@edouard-lopez

Thanks for the tool, I'm running all my other test with jest and was wondering if it is possible to use it for nexpect test?

Test

import nexpect from 'nexpect';

nexpect
  .spawn('yarn', ['start'])
  .expect('hello')
  .run(function(err) {
    if (!err) {
      console.log('hello was echoed');
    }
  });

Output

Currently I got

❯ node_modules/.bin/jest --verbose --watch ./src/__tests__/cli.test.ts
FAIL  src/__tests__/cli.test.ts
  ● Test suite failed to run

    Your test suite must contain at least one test.

      at onResult (node_modules/jest-cli/node_modules/@jest/core/build/TestScheduler.js:175:18)
      at node_modules/emittery/index.js:260:13
          at Array.map (<anonymous>)
      at Emittery.emit (node_modules/emittery/index.js:258:23)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.132 s
Ran all test suites matching /.\/src\/__tests__\/cli.test.ts/i.

Active Filters: filename /./src/__tests__/cli.test.ts/
 › Press c to clear filters.

Watch Usage
 › Press a to run all tests.
 › Press f to run only failed tests.
 › Press o to only run tests related to changed files.
 › Press p to filter by a filename regex pattern.
 › Press t to filter by a test name regex pattern.
 › Press q to quit watch mode.
 › Press Enter to trigger a test run.

  ●  Cannot log after tests are done. Did you forget to wait for something async in your test?
    Attempted to log "hello was echoed".

      10 |   });
      11 |

      at console.log (node_modules/jest-cli/node_modules/@jest/console/build/CustomConsole.js:187:10)
      at src/__tests__/cli.test.ts:12:17
      at ChildProcess.<anonymous> (node_modules/nexpect/lib/nexpect.js:303:9)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions