Open alexanderism55 opened 2 years ago
Week 1
Understanding Jest was quite easy. The entire idea of testing was far more easier than what my fears can justify. In fact testing helped me write my function better, or shall i say it helped me think how to write better function.
I do not know why but I couldn't get the 'description', and the 'it' function rolling. Also i coudnt export my function using 'module.exports = code ' and import using 'code = require './location'. When I did that, it said that require was not defined. So it gave me an option to press change to "enp or ens" i m not sure but when i pressed it it transforms it self to 'import code from location'.
`function secondsChange(hours, minutes) { if (hours < 0) { return 'Not a valid number'; } else if (minutes < 0) { return 'Not a valid number'; } else if(typeof minutes !== 'number') { return 'Not a number'; } else if (typeof hours!== 'number') { return 'Not a number'; } else { const timeInSeconds = hours 60 60 + minutes * 60;
return timeInSeconds;
} }`
`function secondsChange(hours, minutes) { if (hours < 0 || minutes < 0) { return 'Not a valid number'; } else if (typeof minutes !== 'number' || typeof hours !== 'number') { return 'Not a number'; } else { // declaring a new variable called timeInseconds to hold the convertion const timeInSeconds = hours 3600 + minutes 60;
return timeInSeconds;` } }
- I use test instead of description, and i dont use an it statement. However i use equal and expected.
I hope this has become more clear yesterday..but all tests are supposed to follow the logic of describe>it/test>expect
Also i coudnt export my function using 'module.exports = code ' and import using 'code = require './location'. When I did that, it said that require was not defined.
you can just put your function inside the test file now for simplicity..otherwise Jest does not support ES6 modules... and needs some workaround, if you have the function in a separate file..
npm install --save-dev @babel/preset-env
after that create the "babel.config.js" file in the root and that content should be as below
module.exports = {
presets: ['@babel/preset-env', '@babel/preset-react'],
env: {
test: {
plugins: ["@babel/plugin-transform-runtime"]
}
}
};
I do not know why but I couldn't get the 'description', and the 'it' function rolling.
it is just supposed to be a description of what you are doing, a bit like a comment
Week 2
- Nothing so far everything is going super smooth. I did 424 tests which super cool.
wow, nice job Alex πͺ
- Syntax for the test is very easy to break and can get really confusing, i broke the test so many times.
yes, I feel your pain..many brackets and curly braces π it is good practice though! you will be a master spotter
Learning Objectives
Priorities: π₯, π£, π₯, π (click to learn more)
There is a lot to learn in this repository. If you can't master all the material at once, that's expected! Anything you don't master now will always be waiting for you to review when you need it. These 4 emoji's will help you prioritize your study time and to measure your progress: - π₯: Understanding this material is required, it covers the base skills you'll need to move on. You do not need to finish all of them but should feel comfortable that you could with enough time. - π£: You have started all of these exercises and feel you could complete them all if you just had more time. It may not be easy for you but with effort you can make it through. - π₯: You have studied the examples and started some exercises if you had time. You should have a big-picture understanding of these concepts/skills, but may not be confident completing the exercises. - π: These concepts or skills are not necessary but are related to this module. If you are finished with π₯, π£ and π₯ you can use the π exercises to push yourself without getting distracted from the module's main objectives. ---
1. Remix
Practice studying and remixing other people's solutions to coding challenges. Create your own solutions by mixing and matching pieces from other people's code.
2. Write
3. Review