Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //package.json
- {
- "name": "testnode",
- "version": "1.0.0",
- "description": "Testing project for Node.js",
- "main": "index.js",
- "scripts": {
- "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
- },
- "author": "avr39-ripe",
- "license": "ISC",
- "devDependencies": {
- "jest": "^27.0.3"
- },
- "jest": {
- "testMatch": [
- "**/__tests__/**/*.?(m|c)js?(x)",
- "**/?(*.)(spec|test).?(m|c)js?(x)"
- ],
- "moduleFileExtensions": [
- "js",
- "cjs",
- "mjs"
- ]
- }
- }
- // end of package.json
- // functions.mjs
- 'use strict'
- const functions = {
- add: (a,b) => { return a + b;},
- sub: (a,b) => { return a - b +1;}
- }
- export default functions;
- // end of functions.mjs
- // functions.test.mjs
- import functions from './functions.mjs';
- //console.log(functions.add(2,2));
- //console.log(functions.sub(4,2));
- test('Adds 2 + 2 expext 4', ()=>{
- expect(functions.add(2,2)).toBe(4);
- });
- test('Subtracts 4 - 2 expext 2', ()=>{
- expect(functions.sub(4,2)).toBe(2);
- });
- // end of functions.tset.mjs
Add Comment
Please, Sign In to add comment