久久久久久久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 文件中正確地要求模塊的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                限時(shí)送ChatGPT賬號(hào)..

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

                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
                    });
                });
                

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

                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
                

                但現(xiàn)在我在運(yùn)行測試時(shí)收到以下錯(cuò)誤:

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

                ReferenceError: 未定義期望

                ReferenceError: expect is not defined

                這似乎是有道理的——它怎么知道我的測試中對 expect 的引用指的是由 expect.js 庫導(dǎo)出的內(nèi)容?

                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 庫肯定會(huì)被加載,就好像我將路徑更改為不存在的東西然后 mocha 說:

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

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

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

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

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

                推薦答案

                您正確地需要模塊,但正如您所發(fā)現(xiàn)的,模塊導(dǎo)出的符號(hào)不會(huì)自動(dòng)找到自己進(jìn)入全局空間.您可以使用自己的幫助模塊來解決此問題.

                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.

                創(chuàng)建test/helper.js:

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

                并將您的 test/mocha.opts 設(shè)置為:

                --require test/helper
                

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

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

                相關(guān)文檔推薦

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

                          主站蜘蛛池模板: 国产精品久久久久久吹潮 | 欧美不卡在线 | 成人免费在线观看视频 | 中文字幕视频在线观看 | 国产一区二区三区四区 | 亚洲高清视频一区二区 | 精品国产一区二区三区性色av | 亚洲精品高清视频 | 日韩中文字幕免费在线观看 | 国产美女自拍视频 | 欧美99 | 99精品免费在线观看 | 欧美日本在线观看 | 亚洲有码转帖 | 国产精品一区二区av | 久久久久电影 | 国产日韩在线观看一区 | 亚洲欧美日韩久久久 | 国产精品一区二区三区久久久 | 男女羞羞视频网站 | 亚洲精品乱码久久久久久黑人 | 精品粉嫩aⅴ一区二区三区四区 | 蜜桃臀av一区二区三区 | 久久男人 | 久久久女女女女999久久 | 欧美黄色一区 | 精品久久国产老人久久综合 | 国产精品综合色区在线观看 | 91夜色在线观看 | 五月激情综合网 | 亚洲视频在线播放 | 久久久999成人 | 国产一区二区三区视频免费观看 | 精品成人av | 操皮视频| 成人国产精品久久 | 日韩一区中文字幕 | 精品久久久久久久久久久 | 中文字幕视频在线观看 | 精品一二区 | 亚洲精品成人网 |