【问题标题】:Replacing Chai Assertion Library in Intern替换实习生中的 Chai 断言库
【发布时间】:2013-05-21 22:14:52
【问题描述】:

现在我已经让 Intern 运行一些测试,我想用 expect.js 库替换 Chai 断言库。 Expect.js 是我使用 NPM 下载到我的项目中的 Node 模块。我一直在查看以下资源,以拼凑如何使用 Intern 提供的 dojo/node loader 插件导入模块,但我还没有完全掌握它。我要么错误地使用了 loader.packages,要么没有在我的测试文件中使用正确的路径来包含模块。

Can't get Intern to run Node.js Module

dojo/node

AMD API Wiki re:包

  1. 我的项目层次结构(如果有最佳实践或更好的方法来使用节点模块设置我的项目,我可以轻松更改层次结构)

    APEFIntern/
        apeform/
            lib/
                sinon.js           - Mocking library
            node_modules/
                expect/
                    expect.js      - Node package
            test/
                intern.js          - Intern configuration
                spec_inwf.js       - Tests for inwf.js
            inwf.js                - Code to test
        intern/
    
  2. 实习配置文件

    // ...
    
    loader: {
        // Pretty sure I need to register the package for the loader, not I'm not positive on the correct path to use.
        //packages: [ 'apeform/node_modules/expect' ]
        packages: [ 'apeform' ]
        //packages: [ 'expect' ]
    },
    
    // Non-functional test suite(s) to run in each browser
    suites: [ 'apeform/test/spec_inwf' ],
    
    // ...
    
  3. 测试文件 - 根据另一个问题中的 cmets,我尝试了不同的方式来引用节点模块。

    define([
        'intern!bdd',
        //'intern/chai!expect',
        //'intern/dojo/node!expect',
        //'intern/dojo/node!./apeform/node_modules/expect/expect'
        'intern/dojo/node!apeform/node_modules/expect',
        'apeform/lib/sinon.js',
        'apeform/inwf.js'
    ], function (bdd, expect) {
        with (bdd) {
            // Tests ...
    });
    

我正在尝试替换 Intern 中存在的断言库,以便我可以针对 IE 6 运行测试。我知道有适用于 IE 6-8 的 Intern 的 Geezer 分支,但看起来断言库是分支之间的唯一区别,我更喜欢期望语法而不是断言。

【问题讨论】:

    标签: intern


    【解决方案1】:

    Expect.js 安装到包含“.js”的文件夹中。

    尝试在上述设置中使用'intern/dojo/node!./apeform/node_modules/expect.js'

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-26
      • 1970-01-01
      • 2012-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多