2017-04-18 65 views
0

按通話https://medium.com/p/b06559b35459/info摩卡安詳-JS

當我試圖

import `{describe, it} from '@types/mocha' 

我看到

Error:- 
/node_modules/@types/mocha/index.d.ts' is not a module 

按在寧靜-JS項目的例子: - 寧靜-js /示例/ todomvc-量角器-摩卡

serenity: { 
    dialect: 'mocha', 
    crew: [ 
     crew.serenityBDDReporter(), 
     crew.consoleReporter(), 
     crew.Photographer.who(_ => _ 
      .takesPhotosOf(_.Tasks_and_Interactions) 
      .takesPhotosWhen(_.Activity_Finishes) 
     ) 
    ] 
}, 

當在master分支protractor.conf.js中添加時,它不會拾取特徵文件。 https://github.com/serenity-js/tutorial-from-scripts-to-serenity.git

請問我該如何在項目中使用摩卡?

回答

0

Mocha'sdescribeit功能在global scope@types/mocha定義reflect that定義。 這意味着你不需要明確導入它們,因爲根本不必安裝該@types/mocha依賴性使得提供給TypeScript編譯器的定義:

默認情況下,所有可見「@types」包包含在你的彙編。任何封閉文件夾的node_modules/@types中的包都被視爲可見;具體來說,這意味着在./node_modules/@types/,../node_modules/@types/,../../node_modules/@types/等內的包。

- TypeScript manual


請注意,使用寧靜/ JS與摩卡在Serenity/JS Handbook描述。

您可能還會發現example project有用。