I wrote a JavaScript test using Mocha. In my project I have folder named "helpers" with export modules like back_to_main_menu
, go_Offline
, go_Online
, etc. I also have another folder where we can find files with single test.
Every file starts with a lot of lines which look like
const {someFunction} = require(‘../helpers/someFunction’)
I want to ask you how to organize it better and avoid this many lines of code in every test file. I don't want to put all the helper functions in one file, because I want to keep quick overview of the names of functions.
Consider combining your test files into 1 test file, as this will reduce the imports. If this makes it too difficult to visualize your tests, mocha has a solution for this.
Nest your describe/it statements describe('a big section of code'){ it.('should do a thing'){ it.('should do a sub task of the thing'){
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.