Richard Manansala
Richard Manansala

Reputation: 54

How to not include mocha (TDD) functions like "describe" and "it" in my src folder and only contain them in test folder? [TS]

Mocha.js functions like describe() and it() are available everywhere in my project, but I only want them to be only accessible and callable in my "test" folder. Is there any way to do that?

P.S. I'm using typescript if that makes a difference.

Upvotes: 0

Views: 72

Answers (1)

laruiss
laruiss

Reputation: 3816

I think your question is really vague. Still I am going to try to answer assming that you use eslint...

In your .eslintrc.js (or eslint config file), you may have:

module.exports = {
  env: {
    browser: true,
    es6: true,
    node: true,
    mocha: true
   }
   (...)

Where you should have:

module.exports = {
  env: {
    browser: false,
    es6: true,
    node: true
  },

  (...)

  overrides: [
    {
      files: 'test/**/*.spec.js',
      env: {
        mocha: true,
      },
    },
  ],

Upvotes: 1

Related Questions