1

Example I have a file called apiConfig.js

With a simply line of code:

const apiVersion = 'v1';

If I create a file called apiConfig.test.js

How do I write the code to test the const?

Joundill
  • 6,828
  • 12
  • 36
  • 50
Moojjoo
  • 729
  • 1
  • 12
  • 33

1 Answers1

2

This is more of a design issue than mechanics.

You should ask yourself why you want to test const.

I like the advice from here to split your code into two parts - one that is parameterized and can be tested properly, and the other which encodes the "constness".

treecoder
  • 43,129
  • 22
  • 67
  • 91