Home

CATEGORY
  • iplug2 (6)
  • Raspberry Pi (5)
  • Amazon Web Service (5)
  • note (4)
  • Google Cloud Platform (3)
  • Unclassified (2)
  • Node.js (2)
  • reactjs (1)
  • jQuery (1)
  • Spring Boot (1)
  • Project (1)
  • Linux (1)
  • LINE (1)
  • mocha.opts, 더 이상 사용하지 마세요.

    node.js 서버의 테스트를 위해, 많은 곳에서 mocha가 사용되고 있습니다. 웹 상 각종 튜토리얼을 통해 mocha를 설치했다면 mocha.opts 파일을 만들어 설정했을 수도 있습니다.

    mocha.opts 파일이 있는 상태에서 테스트를 실행해보면, 아래 Warning 메시지가 나타납니다.

    (node:5199) DeprecationWarning: Configuration via mocha.opts is DEPRECATED and will be removed from a future version of Mocha. Use RC files or package.json instead.

    해석해보면, mocha.opts 파일은 더 이상 사용되지 않고 이후 버전에서는 기능이 삭제될 것일가고 합니다.

    저는 mocha.opts 대신, .mocharc.json 파일을 사용하는 것을 추천합니다.

    .mocharc.json 파일 작성법

    package.json이 위치한 디렉터리에서 touch .mocharc.json 한 후, 아래처럼 내용을 채워보세요.

    {
      "diff": true,
      "extension": ["js"],
      "package": "./package.json",
      "reporter": "spec",
      "slow": 75,
      "timeout": 2000,
      "ui": "bdd",
      "spec": ["test/*.js", "test/**/*.js"]
    }
    

    spec 부분은 사용하시는 project에 맞게 바꿔 주셔야 합니다.

    Referenced : https://mochajs.org/#configuring-mocha-nodejs