久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<i id='OlxNL'><tr id='OlxNL'><dt id='OlxNL'><q id='OlxNL'><span id='OlxNL'><b id='OlxNL'><form id='OlxNL'><ins id='OlxNL'></ins><ul id='OlxNL'></ul><sub id='OlxNL'></sub></form><legend id='OlxNL'></legend><bdo id='OlxNL'><pre id='OlxNL'><center id='OlxNL'></center></pre></bdo></b><th id='OlxNL'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='OlxNL'><tfoot id='OlxNL'></tfoot><dl id='OlxNL'><fieldset id='OlxNL'></fieldset></dl></div>

        <bdo id='OlxNL'></bdo><ul id='OlxNL'></ul>
    1. <small id='OlxNL'></small><noframes id='OlxNL'>

    2. <tfoot id='OlxNL'></tfoot>

      <legend id='OlxNL'><style id='OlxNL'><dir id='OlxNL'><q id='OlxNL'></q></dir></style></legend>

      如何從 mocha.opts 文件中正確地要求模塊

      How to properly require modules from mocha.opts file(如何從 mocha.opts 文件中正確地要求模塊)

      <tfoot id='jr6tL'></tfoot>
      <i id='jr6tL'><tr id='jr6tL'><dt id='jr6tL'><q id='jr6tL'><span id='jr6tL'><b id='jr6tL'><form id='jr6tL'><ins id='jr6tL'></ins><ul id='jr6tL'></ul><sub id='jr6tL'></sub></form><legend id='jr6tL'></legend><bdo id='jr6tL'><pre id='jr6tL'><center id='jr6tL'></center></pre></bdo></b><th id='jr6tL'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='jr6tL'><tfoot id='jr6tL'></tfoot><dl id='jr6tL'><fieldset id='jr6tL'></fieldset></dl></div>

          <bdo id='jr6tL'></bdo><ul id='jr6tL'></ul>

            <small id='jr6tL'></small><noframes id='jr6tL'>

            1. <legend id='jr6tL'><style id='jr6tL'><dir id='jr6tL'><q id='jr6tL'></q></dir></style></legend>
                <tbody id='jr6tL'></tbody>

              • 本文介紹了如何從 mocha.opts 文件中正確地要求模塊的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                我在 mocha 單元測試中使用了 expect.js 庫.目前,我需要在每個文件的第一行使用該庫,如下所示:

                I'm using the expect.js library with my mocha unit tests. Currently, I'm requiring the library on the first line of each file, like this:

                var expect = require('expect.js');
                
                describe('something', function () {
                    it('should pass', function () {
                        expect(true).to.be(true); // works
                    });
                });
                

                如果可能,我想從每個文件的第一行刪除樣板要求代碼,并讓我的單元測試神奇地了解 expect.我想我可以使用 mocha.opts 文件來做到這一點:

                If possible, I'd like to remove the boilerplate require code from the first line of each file, and have my unit tests magically know about expect. I thought I might be able to do this using the mocha.opts file:

                --require ./node_modules/expect.js/index.js
                

                但現在我在運行測試時收到以下錯誤:

                But now I get the following error when running my test:

                ReferenceError: 未定義期望

                ReferenceError: expect is not defined

                這似乎是有道理的——它怎么知道我的測試中對 expect 的引用指的是由 expect.js 庫導出的內容?

                This seems to make sense - how can it know that the reference to expect in my tests refers to what is exported by the expect.js library?

                expect 庫肯定會被加載,就好像我將路徑更改為不存在的東西然后 mocha 說:

                The expect library is definitely getting loaded, as if I change the path to something non-existent then mocha says:

                錯誤:找不到模塊'./does-not-exist.js'"

                "Error: Cannot find module './does-not-exist.js'"

                有什么方法可以完成我想要的嗎?如果可能有幫助的話,我正在從一個 gulp 任務中運行我的測試.

                Is there any way to accomplish what I want? I'm running my tests from a gulp task if perhaps that could help.

                推薦答案

                您正確地需要模塊,但正如您所發現的,模塊導出的符號不會自動找到自己進入全局空間.您可以使用自己的幫助模塊來解決此問題.

                You are requiring the module properly but as you figured out, the symbols that the module export won't automatically find themselves into the global space. You can remedy this with your own helper module.

                創建test/helper.js:

                var expect = require("expect.js")
                
                global.expect = expect;
                

                并將您的 test/mocha.opts 設置為:

                --require test/helper
                

                這篇關于如何從 mocha.opts 文件中正確地要求模塊的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Browserify, Babel 6, Gulp - Unexpected token on spread operator(Browserify,Babel 6,Gulp - 傳播運算符上的意外令牌)
                Is it possible to pass a flag to Gulp to have it run tasks in different ways?(是否可以將標志傳遞給 Gulp 以使其以不同的方式運行任務?)
                Why do we need to install gulp globally and locally?(為什么我們需要在全局和本地安裝 gulp?)
                How to run Gulp tasks sequentially one after the other(如何一個接一個地依次運行 Gulp 任務)
                Stylesheet not loaded because of MIME-type(由于 MIME 類型而未加載樣式表)
                Visual Studio 2015 crashes when opening Javascript files(打開 Javascript 文件時 Visual Studio 2015 崩潰)
                    <tbody id='svADk'></tbody>
                    <legend id='svADk'><style id='svADk'><dir id='svADk'><q id='svADk'></q></dir></style></legend>

                    • <bdo id='svADk'></bdo><ul id='svADk'></ul>
                      <i id='svADk'><tr id='svADk'><dt id='svADk'><q id='svADk'><span id='svADk'><b id='svADk'><form id='svADk'><ins id='svADk'></ins><ul id='svADk'></ul><sub id='svADk'></sub></form><legend id='svADk'></legend><bdo id='svADk'><pre id='svADk'><center id='svADk'></center></pre></bdo></b><th id='svADk'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='svADk'><tfoot id='svADk'></tfoot><dl id='svADk'><fieldset id='svADk'></fieldset></dl></div>

                      <tfoot id='svADk'></tfoot>

                          <small id='svADk'></small><noframes id='svADk'>

                          主站蜘蛛池模板: 日本又色又爽又黄的大片 | 午夜在线免费观看视频 | 在线免费黄色 | 亚州精品天堂中文字幕 | 亚洲欧美日韩电影 | 91亚洲精选| 一级做a爰片性色毛片16 | 一区二区三区国产 | 免费国产黄网站在线观看视频 | 久久久精品久久 | 北条麻妃国产九九九精品小说 | 911网站大全在线观看 | 国产www成人 | 午夜天堂精品久久久久 | 午夜大片| 射久久 | 欧美日韩精品在线一区 | 国产在线中文字幕 | 麻豆久久久 | 国产成人免费在线 | 欧美乱人伦视频 | 亚洲国产成人精品女人久久久野战 | 在线免费观看毛片 | 日韩成人精品在线 | 嫩草视频网站 | 中文字幕在线电影观看 | 欧美在线观看一区 | 91麻豆精品国产91久久久久久 | 国产ts一区 | 91精品久久久久久综合五月天 | 亚洲www| 久久a久久 | 自拍偷拍亚洲视频 | 久久在线 | 91短视频网址 | 欧美成人精品二区三区99精品 | 午夜av成人 | 黄色91在线 | 国产午夜影院 | 欧美视频精品 | 一级a性色生活片久久毛片波多野 |