Skip to content

EKI-INDRADI/eki-latihan-nodejs-unit-test-javascript-commonjs

Repository files navigation

JEST NODEJS UNIT TEST (Javascript CommonJs)

npm init

package.json edit/tambahkan :

"type" : "commonjs"  ->  "type" : "module"


"scripts": {
    "test":  "jest"    or   "./node_modules/.bin/jest"
  }

depedency :

npm install jest --save-dev,
npm install babel-jest --save-dev
npm install @babel/preset-env --save-dev
npm install @babel/plugin-transform-runtime --save-dev

or 

npm i

run windows :

node_modules/.bin/jest

run unix (linux/mac) :

./node_modules/.bin/jest

run :

npm run test

easy run (using npx , for auto detect node_modules/.bin/) :

npx jest

Note :

  • Command Line untuk run test spesific file

./node_modules/.bin/jest --runTestsByPath test/_1_sum.test.js or npx jest --runTestsByPath test/_1_sum.test.js or npx jest test/_1_sum.test.js

  • Command Line untuk run test spesific file by function test name
npx jest --testNamePattern "test sum function 2"

or

npx jest --t "test sum function 2"

or

(optional) visual studio code , install extention "Jest" supaya bs test speisifc file test atau kelik kanan function

(supaya bs running speisifc by function name) , dll

"run test at cursor" 

(test 1 file)

"run test at current file"

EKI INDRADI

"TIME > KNOWLEDGE > MONEY". #2023_3_DIGIT_MOTIVATION

Reference :

🔗 https://github.com/EKI-INDRADI/eki-latihan-nodejs-unit-test-javascript-module

🔗 https://www.youtube.com/watch?v=UNaYui-EG_8&ab_channel=ProgrammerZamanNow

🔗 https://docs.google.com/presentation/d/1f3yg05_bX0HFybD9qBCqPq64l8Tiu-f4iWhCQBMG_eM/edit

🔗 https://github.com/ProgrammerZamanNow/belajar-nodejs-unit-test

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published