Intern 4 Dojo加载程序无法在ArcGIS JavaScript API中找到Dojo库。有谁知道如何使用Dojo和ArcGIS JavaScript API制作最新版本的Intern?
old fix不再有效。实习生说:
PS C:\UniServerZ\www\HelloIntern2> .\node_modules\.bin\intern
Config has unknown option "useLoader"
(????)?????
ReferenceError: define is not defined
at Object.<anonymous> <tests\unit\ViewByAttributeTest.js:1:63>
at Module._compile <module.js:652:30>
at Object.Module._extensions..js <module.js:663:10>
at Module.load <module.js:565:32>
at tryModuleLoad <module.js:505:12>
at Function.Module._load <module.js:497:3>
at Module.require <module.js:596:17>
at require <internal\module.js:11:18>
at Node.loadScript <src\lib\executors\Node.ts:260:5>
at Node._loader <src\loaders\default.ts:10:16>
此外,鉴于本帖末尾的intern.json文件,实习生说:
PS C:\UniServerZ\www\HelloIntern2> .\node_modules\.bin\intern
(????)?????
Error: Cannot find module 'node_modules/dojo/dojo.js' from 'C:\UniServerZ\www\He
lloIntern2'
at Function.module.exports [as sync] <node_modules\resolve\lib\sync.js:40:15>
at Node.loadScript <src\lib\executors\Node.ts:264:13>
at <src\loaders\dojo.ts:17:15>
at Node.Executor.registerLoader <src\lib\executors\Executor.ts:468:37>
at Object.<anonymous> <src\loaders\dojo.ts:6:7>
at Module._compile <module.js:652:30>
at Object.Module._extensions..js <module.js:663:10>
at Module.load <module.js:565:32>
at tryModuleLoad <module.js:505:12>
at Function.Module._load <module.js:497:3>
intern.json:
{
"loader" : {
"script" : "dojo",
"options" : {
"packages" : [{
"name" : "zian",
"location" : "/zian"
}, {
"name" : "dgrid",
"location" : "http://js.arcgis.com/4.6/dgrid"
}, {
"name" : "dijit",
"location" : "http://js.arcgis.com/4.6/dijit"
}, {
"name" : "esri",
"location" : "http://js.arcgis.com/4.6/esri"
}, {
"name" : "dojo",
"location" : "http://js.arcgis.com/4.6/dojo"
}, {
"name" : "dojox",
"location" : "http://js.arcgis.com/4.6/dojox"
}, {
"name" : "moment",
"location" : "http://js.arcgis.com/4.6/moment"
}
]
}
},
"filterErrorStack" : false,
"suites" : ["tests/unit/*.js"],
"environments" : ["chrome", "node"]
}
最后,为了完整起见,这里是完整的目录结构:
app has: calc.js and index.js
js has: starter.js
node_module has: tons and tons of folder...
test has: unit has: ViewByAttributeTest.js
zian has: ViewByAttribute.js
root of the folder has the above folders and: index.html, index.js, intern.json, package.json, and package-lock.json
的package.json:
{
"name": "helloworldcdnapi",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"author": "Zian Choy",
"license": "ISC",
"dependencies": {
"intern": "^4.0.0-rc.1"
}
}
ViewByAttributeTest.js
define([
'require'
], function (require) {
var registerSuite = intern.getInterface('object').registerSuite;
var assert = intern.getPlugin('chai').assert;
registerSuite('ViewByAttribute', {
'default data': function () {
assert.strictEqual(1, 1, '1 is 1.');
}
});
});
顺便说一下,如果你读到这一点,我希望你能理解计算机中的幽默,而不是认识到1等于1。
答案 0 :(得分:0)
您需要做一些事情才能使它生效。首先,您需要添加一个自定义加载程序以加载dojo
,然后需要更改script
以引用intern.json
中的新dojo加载程序文件。该文件将类似于:
intern.registerLoader(function(options) {
// do checks here
return intern.loadScript(<location of your dojo file in arcgis js api>)
.then(function() {
//do stuff here
})
});
答案 1 :(得分:0)
有一个文档来说明在WebAppbuilder for ArcGIS上设置实习生4的过程。 WAB使用ArcGIS API for Javascript。