Load external js resource file

Get help with testing, discuss unit testing strategies etc.
Post Reply
User avatar
claudia_
Posts: 8
Joined: Mon May 14, 2018 3:05 pm

Load external js resource file

Post by claudia_ » Mon May 14, 2018 4:00 pm

Hi,

I've written some tests for a Sencha Extjs app (Extjs version 6.5.3 and I'm using Siesta 4.4.4).

I need to load an external javascript file which contains some functions I need inside my tests.

I've already added an external js file inside the 'preload' option of my harness file but I cannot execute the functions defined in those external js (e.g. I get 'function not defined method').

Can you explain which is the best practice about loading external js files for having custom functions to use inside Siesta tests ?

Any hint is appreciated.
Regards,

Claudia

User avatar
mats
Premium Member
Premium Member
Posts: 15621
Joined: Sat Dec 19, 2009 11:41 pm
Location: Sweden
Contact:

Re: Load external js resource file

Post by mats » Mon May 14, 2018 4:33 pm

Could you please upload a ZIP file showing your test setup?
Tired of debugging javascript errors in web applications? Try our new error logging service RootCause, or read more on the Sencha blog

@bryntum
Facebook
API documentation

User avatar
claudia_
Posts: 8
Joined: Mon May 14, 2018 3:05 pm

Re: Load external js resource file

Post by claudia_ » Mon May 14, 2018 5:27 pm

Attached the ZIP file showing my test setup.
Attachments
Setup.zip
(1.24 KiB) Downloaded 102 times

User avatar
nickolay
Core Developer
Core Developer
Posts: 3405
Joined: Mon May 16, 2011 10:48 am

Re: Load external js resource file

Post by nickolay » Tue May 15, 2018 10:12 am

I've already added an external js file inside the 'preload' option of my harness file but I cannot execute the functions defined in those external js (e.g. I get 'function not defined method').
Are there any 404 errors? How exactly you call those external functions (your setup does not seem to contain any tests). See also https://www.bryntum.com/docs/siesta/#!/ ... test_class
We offer training in both Ext JS and our products, read more here.
Read the API documentation

User avatar
claudia_
Posts: 8
Joined: Mon May 14, 2018 3:05 pm

Re: Load external js resource file

Post by claudia_ » Tue May 15, 2018 11:23 am

Attached new setup zip with one test file inlcuded plus the js call to the external js resource.
Besides I have no 404 code about the loaded resources on my console network panel..
I simply call the function as normal function call.
Attachments
BasicSetup.zip
Setup with one test file
(1.48 KiB) Downloaded 107 times

User avatar
nickolay
Core Developer
Core Developer
Posts: 3405
Joined: Mon May 16, 2011 10:48 am

Re: Load external js resource file

Post by nickolay » Tue May 15, 2018 11:29 am

Weird, this definetely should work. If you comment the call to external function - does the check about Ext pass? What if you switch it to explicit global assignment:

Code: Select all

myTestSetup = function (){
We offer training in both Ext JS and our products, read more here.
Read the API documentation

User avatar
claudia_
Posts: 8
Joined: Mon May 14, 2018 3:05 pm

Re: Load external js resource file

Post by claudia_ » Tue May 15, 2018 11:44 am

If I comment the call to external function the check about Ext does pass.

After using explicit global assignment on my external js file, the function call does execute correctly.

So this has solved my issue
thanks

Post Reply