3.5.9 • Published 12 months ago

xrm-mock v3.5.9

Weekly downloads
567
License
MIT
Repository
github
Last release
12 months ago

Build Status npm version Downloads Test Coverage

:books: xrm-mock

Join the chat at https://gitter.im/xrm-mock/Lobby

xrm-mock is a fake implementation of the Dynamics 365 Client API and Xrm object model. Written in TypeScript against @types/xrm definitions.

xrm-mock-generator is an opinionated toolset for building fake Xrm objects.

Installing

For the latest stable version

npm install xrm-mock -D

Usage

Import XrmMockGenerator in your unit test file

import { XrmMockGenerator } from "xrm-mock";

Initialise a global Xrm object

XrmMockGenerator.initialise();

Customise your form by adding attributes

XrmMockGenerator.Attribute.createBool("new_havingfun", true);

Invoke your code and make your assertions

Contact.onLoad();
expect(Xrm.Page.getAttribute("new_havingfun").getValue()).toBe(true);

Example

This example demonstrates a script with an onLoad event handler registered on a contact form. When invoked, it changes the firstname attribute's value to Bob. See the Wiki for a visual demo.

src/contact.ts

export default class Contact {
 public static onLoad() {
   Xrm.Page.getAttribute("firstname").setValue("Bob");
 }
}

test/contact.test.ts

import Contact from "../src/contact";
import { XrmMockGenerator } from "xrm-mock";

describe("Contact", () => {
  beforeEach(() => {
    XrmMockGenerator.initialise();
    XrmMockGenerator.Attribute.createString("firstname", "Joe");
  });

  it("should initially be called Joe", () => {
    let name = Xrm.Page.getAttribute("firstname").getValue();
    expect(name).toBe("Joe"); // Pass
  });

  it("should change name to Bob onLoad", () => {
    Contact.onLoad();
    let name = Xrm.Page.getAttribute("firstname").getValue();
    expect(name).toBe("Bob"); // Pass
  });
});

Contribute

  • Submit bugs
  • Implement a new function by inheriting @types/Xrm
    • Test your code using npm run test
    • Lint your code using npm run lint
    • Build your code using npm run build

Roadmap

  • Increased test coverage
  • Increased implementation against different versions of @types/Xrm (8.2 and 9)
  • Automatic generation of attributes from a given Dynamics organisation
3.5.9

12 months ago

3.5.8

12 months ago

3.5.7

3 years ago

3.5.6

3 years ago

3.5.5

3 years ago

3.5.4

3 years ago

3.5.3

3 years ago

3.5.1

3 years ago

3.5.0

3 years ago

3.4.21

4 years ago

3.4.20

4 years ago

3.4.18

4 years ago

3.4.17

4 years ago

3.4.16

4 years ago

3.4.15

5 years ago

3.4.13

5 years ago

3.4.12

5 years ago

3.4.10

6 years ago

3.4.9

6 years ago

3.4.8

6 years ago

3.4.7

6 years ago

3.4.6

6 years ago

3.4.5

6 years ago

3.3.5

6 years ago

3.2.3

6 years ago

3.1.3

6 years ago

3.1.2

6 years ago

3.1.1

6 years ago

3.1.0

6 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.4.5

6 years ago

2.4.4

6 years ago

2.4.3

6 years ago

2.4.1

6 years ago

2.4.0

6 years ago

2.3.0

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.9

7 years ago

2.0.8

7 years ago

2.0.7

7 years ago

2.0.6

7 years ago

2.0.5

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.2.8

7 years ago

1.2.7

7 years ago

1.2.6

7 years ago

1.2.5

7 years ago

1.2.4

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago