Welcome to the Linux Foundation Forum!

Writing Unit Test - using jest Framework

Hello,

I'm trying the examples given in the course and I've found an issue, maybe I'm doing something wrong, that's why I'm writing in this forum.

is it possible that ./node_modules/.bin/jest doesn't exists?

I can't execute the exercise, using node, throws the 'test is not defined' as expected. Then, when try to execute using 'jest', I can't find the module.

Kind regards.

Comments

  • sanchil
    sanchil Posts: 6

    you will need to install jest the same way you installed tap. The instruction for the same is missing in the course. Maybe it was deliberate as a learning aid or maybe an oversight.

    Please run the following to install jest and retry.

    $ npm i -D jest
    or
    $ npm install --save-dev jest

  • Yes using Jest instead is an optional exercise left up to the reader. It's good that you hit these problems, so you can figure out why.

    In the case of Jest, the reason you can't run it directly with Node is because Jest provides it's own environment (it's a test FRAMEWORK instead of simply a test RUNNER), so you need to use the jest executable to run your tests.

  • cafaray
    cafaray Posts: 2

    Great! I've done the exercise. :)

  • 🙌 nice job @cafaray

This discussion has been closed.

Categories

Upcoming Training