@wycliffeassociates/xrm-mock
v0.0.1
Published
A mock implementation of the Xrm object model. Used for testing Dynamics 365 client-side scripts.
Downloads
1
Maintainers
Readme
xrm-mock
A mock implementation of the Xrm.Page object model. Written in TypeScript against @types/xrm definitions.
|Build|Chat|NPM|Coverage|Vulnerabilities|Climate| |-----|----|---|--------|---------------|-------| |||||||
:books: Usage:
Clone, Fork or install the repository via
npm i xrm-mock
Install generation tool
npm i xrm-mock-generator
[link] (biased recommendation)Create a file for your entity form:
src/contact.js
(function () {
"use strict";
var Contact = () => { };
Contact.prototype.onLoad = () => {
Xrm.Page.getAttribute("firstname").setValue("Bob");
}
// node
module.exports = new Contact();
// browser
global.Contact = new Contact();
}());
- Create a file to test your entity form:
test/contact.test.js
describe("Contact Form", () => {
var XrmMockGenerator = require("xrm-mock-generator");
var ContactForm = require("../src/contact.js");
beforeEach(() => {
XrmMockGenerator.initialise();
XrmMockGenerator.createString("firstname", "Joe");
});
describe("default", () => {
expect(Xrm.Page.getAttribute("firstname").getValue()).toBe("Joe"); // true
});
describe("onLoad", () => {
ContactForm.onLoad();
expect(Xrm.Page.getAttribute("firstname").getValue()).toBe("Bob"); // true
});
});
:heart: Contributing and Project Roadmap:
- Increase test coverage
- Increase implementation
- Include a project like rewire so that non-exported classes can be tested