简体   繁体   中英

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

我不希望在我的实际代码 (src) 中使用 TDD(描述)函数,是否可以只在测试文件夹中访问它们,以便在我不需要它们时它们不会污染我的智能感知?

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,
      },
    },
  ],

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM