Skip to main content

Notifications

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

How to unit test Javascript Web Resources in D365?

Posted on by 57

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.

  • How to unit test Javascript Web Resources in D365?
    Hi ,
    I have the same requirement, just wondering if you managed to implement this.
    If yes, could you please help me with a sample code or blog posts you followed to achieve this.
     
    Thank You,
    Shweta
     
  • Suggested answer
    pratyush369 Profile Picture
    pratyush369 30 on at
    RE: How to unit test Javascript Web Resources in D365?

    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.

    pastedimage1645124283144v1.png

    Regards

  • VivekGupta Profile Picture
    VivekGupta 57 on at
    RE: How to unit test Javascript Web Resources in D365?

    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.

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: How to unit test Javascript Web Resources in D365?

    Hello,

    Check this - github.com/.../fake-xrm-easy-js-samples

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,151 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,993 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans