gpt4 book ai didi

javascript - 实习生 - ReferenceError : document is not defined

转载 作者:行者123 更新时间:2023-11-30 05:31:20 26 4
gpt4 key购买 nike

当我尝试从我的测试文件目录中运行实习生测试时看到此错误消息。目录的(相关)结构是:

  • 测试
    • 资源
      • 休息
        • pickup.js
        • 现金管理.js
      • gitignore
      • intern.js
      • packages.js
      • packages.sample.js
      • ...

inter.js 包含对 suites 部分中的 testFile1.jstestFile2.js 的引用。我对这两个文件的引用方式进行了一些尝试,并收到“无法加载模块...”错误。所以我想现在已经解决了,而 ReferenceError 是我需要弄清楚的问题。我确实检查了现有的线程,但似乎无法解决我的问题。完整的错误消息粘贴在下面。如果需要,我很乐意提供更多相关信息。

谢谢,伊兰

***ReferenceError: document is not defined**
at /Applications/dojo-release-1.10.2/dojo/has.js:31:33
at execModule (/Users/eranbrand/src/MobilePosSolution/ovc-build/ovc-repo/src/test/node_modules/intern/node_modules/dojo/dojo.js:515:54)
at /Users/eranbrand/src/MobilePosSolution/ovc-build/ovc-repo/src/test/node_modules/intern/node_modules/dojo/dojo.js:504:12
at Array.map (native)
at execModule (/Users/eranbrand/src/MobilePosSolution/ovc-build/ovc-repo/src/test/node_modules/intern/node_modules/dojo/dojo.js:499:17)
at /Users/eranbrand/src/MobilePosSolution/ovc-build/ovc-repo/src/test/node_modules/intern/node_modules/dojo/dojo.js:582:7
at guardCheckComplete (/Users/eranbrand/src/MobilePosSolution/ovc-build/ovc-repo/src/test/node_modules/intern/node_modules/dojo/dojo.js:566:4)
at checkComplete (/Users/eranbrand/src/MobilePosSolution/ovc-build/ovc-repo/src/test/node_modules/intern/node_modules/dojo/dojo.js:574:27)
at onLoadCallback (/Users/eranbrand/src/MobilePosSolution/ovc-build/ovc-repo/src/test/node_modules/intern/node_modules/dojo/dojo.js:656:7)
at /Users/eranbrand/src/MobilePosSolution/ovc-build/ovc-repo/src/test/node_modules/intern/node_modules/dojo/dojo.js:761:5*

这是 intern.js 文件的内容:

// Learn more about configuring this file at <https://github.com/theintern/intern/wiki/Configuring-Intern>.
// These default settings work OK for most people. The options that *must* be changed below are the
// packages, suites, excludeInstrumentation, and (if you want functional tests) functionalSuites.

serviceURL = "http://ovc.local:8080/POSMClient/json/process/execute/";


define(['./packages'], function(Packages) {

var returnValue = {
// Configuration options for the module loader; any AMD configuration options supported by the specified AMD loader
// can be used here
loader: {
packages: Packages.packages
},

// The port on which the instrumenting proxy will listen
proxyPort: 9000,

// A fully qualified URL to the Intern proxy
proxyUrl: 'http://localhost:9000/',

// Default desired capabilities for all environments. Individual capabilities can be overridden by any of the
// specified browser environments in the `environments` array below as well. See
// https://code.google.com/p/selenium/wiki/DesiredCapabilities for standard Selenium capabilities and
// https://saucelabs.com/docs/additional-config#desired-capabilities for Sauce Labs capabilities.
// Note that the `build` capability will be filled in with the current commit ID from the Travis CI environment
// automatically
capabilities: {
'selenium-version': '2.39.0'
},

// Browsers to run integration testing against. Note that version numbers must be strings if used with Sauce
// OnDemand. Options that will be permutated are browserName, version, platform, and platformVersion; any other
// capabilities options specified for an environment will be copied as-is
environments: [/*
{ browserName: 'internet explorer', version: '11', platform: 'Windows 8.1' },
{ browserName: 'internet explorer', version: '10', platform: 'Windows 8' },
{ browserName: 'internet explorer', version: '9', platform: 'Windows 7' },
{ browserName: 'firefox', version: '27', platform: [ 'OS X 10.6', 'Windows 7', 'Linux' ] },
{ browserName: 'chrome', version: '32', platform: [ 'OS X 10.6', 'Windows 7', 'Linux' ] },
{ browserName: 'safari', version: '6', platform: 'OS X 10.8' },
{ browserName: 'safari', version: '7', platform: 'OS X 10.9' }*/
],

// Maximum number of simultaneous integration tests that should be executed on the remote WebDriver service
maxConcurrency: 3,

// Whether or not to start Sauce Connect before running tests
useSauceConnect: false,

// Connection information for the remote WebDriver service. If using Sauce Labs, keep your username and password
// in the SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables unless you are sure you will NEVER be
// publishing this configuration file somewhere
webdriver: {
host: 'localhost',
port: 4444
},

// The desired AMD loader to use when running unit tests (client.html/client.js). Omit to use the default Dojo
// loader
useLoader: {
'host-node': 'dojo/dojo',
'host-browser': 'node_modules/dojo/dojo.js'
},

// Non-functional test suite(s) to run in each browser
suites: [
"rest/pickup",
"rest/cashManagement"
],

// Functional test suite(s) to run in each browser once non-functional tests are completed
functionalSuites: [ /* 'myPackage/tests/functional' */ ],

// A regular expression matching URLs to files that should not be included in code coverage analysis
excludeInstrumentation: /^tests\//
}

return returnValue;
});

最佳答案

看起来您正在使用 Dojo 的发布版本,它假设 document 对象可用。要使用该构建,您需要使用 intern-runner 或浏览器客户端 (client.html) 运行 intern。如果您更喜欢使用 Node 客户端 (intern-client) 运行测试,则需要使用 Dojo 的源代码分发或 dojo npm 包。

关于javascript - 实习生 - ReferenceError : document is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26802851/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com