Sitemap

What I learned from code problem solving

1 min readJul 20, 2022

--

I learned TDD(Test Driven Development) today. Using Jest and JavaScript, I made some functions and tests. It looked fine till I actually ran the test.

*The problem was : Test.js kept failing even when it was working when I checked manually with console.log.

*The solution was : instead of calling module.exports one by one functions, I had to gather them together and then call them together like:

module.exports = {function1, function2, function3}

Get Eddie Na’s stories in your inbox

Join Medium for free to get updates from this writer.

then call like:

const myFunctions = require(“./filename”)

then use the functions like:

myFunctions.fucntion1()

*What did I do : I made another function to see if it was the first function’s problem, then realized the test file could only read whatever was exported later. Then I googled “JS module.exports multiple functions” to find the solution.

*What I learned: so, if the code doesn’t work, don’t panic, just keep going. There might be a chance to find what’s wrong when I just keep going to the next step. And, google!

--

--

Eddie Na
Eddie Na

Written by Eddie Na

Software Engineering Student