web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

How to unit test Javascript Web Resources in D365?

(1) ShareShare
ReportReport
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.

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 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

  • VivekGupta Profile Picture
    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
    pratyush369 Profile Picture
    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

  • Community member Profile Picture
    2 on at
    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
     

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Sahan Hasitha Profile Picture

Sahan Hasitha 337

#2
Sohaib Cheema Profile Picture

Sohaib Cheema 104 User Group Leader

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 79 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans