How to unit test Javascript Web Resources in D365?
Please let me know if it is possible to unit test Javascript Web Resources i.e JS Files in Visual Studio 2019 ASP.NET Web Application?
How to get the executionContext & formContext object model in Visual Studio 2019 ASP.NET Web Application?
Methods like formContext.context.getUserName() & formContext.context.getUserId() are used in the Javascript Web Resources (.JS files)
https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/walkthrough-write-your-first-client-script?tabs=unified-interface%2Cunified-add-web-resource#complete-sample-code-used-in-the-walk-through shows sample Javascript Web Resource (.JS file) that I have to unit test.
I am not using TypeScript Web Resources.
Please provide example of how to implement Javascript Web Resources unit testing in D365.
Thanks.
Hi, you can use your browser console and test your code.
Open the form where you want to run your code, and use Xrm.Page instead of formContext and you should be able to test your code snippets there.
Regards
I want to unit test Javascript Web Resources. I am not using Typescript Web Resources.
community.dynamics.com/.../unit-test-case-for-typescript-webresources shows how to write Unit Test Case for Typescript Webresources
I tried using www.nexsoftsys.com/.../unit-test-javascript-in-dynamics-365-using-xrmpage.html but XrmPage-Mock is deprecated. I have to use executionContext & formContext object model.
https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/walkthrough-write-your-first-client-script?tabs=unified-interface%2Cunified-add-web-resource#complete-sample-code-used-in-the-walk-through shows sample Javascript Web Resource (.JS file) that I have to unit test.
Hello,
Check this - github.com/.../fake-xrm-easy-js-samples
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,151 Super User 2024 Season 2
Martin Dráb 229,993 Most Valuable Professional
nmaenpaa 101,156