AnsweredAssumed Answered

dojo.byId intern unit testing error

Question asked by sandhyabaratam@gmail.com on Mar 19, 2020
Latest reply on Mar 19, 2020 by kenbuja

Hi,

I am using intern for unit testing of my custom widget.
I am getting error when I use dojo.byId() in any method of custom widget code. can you please let me know if i have to import any specific library in test class?
If I comment this line dojo.byId() in widget code, Test is getting passed.


1.I have added dojo dependency in node_modules->package.json ->dependencies section
"dojo":"^1.14.0"


2.imported below modules in test class ----
define([
'intern!object',
'intern/chai!assert',
'app/testRoute/Methods',"dojo/_base/declare",
"dojo/dom-construct", "dojo/_base/window", "dojo/_base/lang","esri/layers/FeatureLayer",
'dojo/on',
"dojo/_base/array", "dojo/Deferred"
], function(registerSuite, assert,methods,declare,domConstruct, win, lang,FeatureLayer, on,
arrayUtils, Deferred) {}


3.widget code ,

processCsvData()---
dojo.byId("progressBar").style.display = "none";

 

unit testing Error:
PASS: Test getHashInput (1ms)
FAIL: Test processCsvData (2ms)
TypeError: Cannot read property 'length' of undefined
at Test processCsvData [as test] <tests/unit/testRoute_test.js:114:33>
at <__intern/lib/Test.js:181:24>
at <__intern/browser_modules/dojo/Promise.js:156:41>
at runCallbacks <__intern/browser_modules/dojo/Promise.js:19:22>
at <__intern/browser_modules/dojo/Promise.js:103:21>
at run <__intern/browser_modules/dojo/Promise.js:51:33>
at CallbackQueue.drain <__intern/browser_modules/dojo/CallbackQueue.js:39:35>
at MutationObserver.<anonymous> <__intern/browser_modules/dojo/nextTick.js:52:27>

 

 

Regards,
Sandhya

Outcomes