Code Monkey home page Code Monkey logo

mochafornetsuite's Introduction

Mocha For NetSuite

It is a unit test framework for NetSuite.

NetSuite lacks a unit testeing framework. This repo bridges that gap by exploiting existing open source libraries - Mochajs and Chaijs.

Tests can be ran in the context of Suitelet or Scheduled Script.

What kind of scripts can you test using this framework?

You should write your scripts more as a library which can run in the context of any script (to be more specific - suitelet and scheduled script). You can then load these libraries in the context of suitelet or scheduled script and then write tests for it. For testing user events you may simply want to create, update or delete the record and then do some assertions based on your expectations.

Getting Started

A. Create Your Script

  1. Create a Suitelet or a Scheduled Script
  2. Entry function name - "suite.test.SuiteRunner.suiteletEntry" for Suitelet and "suite.test.SuiteRunner.scheduledEntry" for a Scheduled Script.
  3. Script file - "suite.test.runner.js"
  4. Add Library files exactly in the order
    1. suite.utils.lodash.js
    2. suite.utils.utils.js
    3. suite.utils.eventEmitter.js
    4. suite.utils.fs.js
    5. suite.test.chai.js
    6. suite.test.reporter.js
    7. suite.test.mocha.js
    8. suite.test.sinon.js (optional, if you want to write test spies, stubs and mocks)
    9. suite.test.fakedate.js (optional)
  5. If you are creating scheduled Script, create three parameters
    1. Email Receipients CC, Id: "custscript_suite_test_emails" of type free-form-text. value must be an Array, eg: ["[email protected]"]
    2. Unite Test Suite Files Id:custscript_suite_test_files, of type free-form-text. Value must be an Array, eg: ["suite.testsuite.credstoresuites.js", "suite.testsuite.suite1.js"]
    3. Email To Employee: Id "custscript_suite_test_email_to" of type List/Record pointing to Employee

B. Create Folders

  1. "testsuites" under standard folder "suitescripts". It assumes all testsuites/test files are located in this folder.

B. Writing tests

  1. Make sure all libraries that needs to be loaded are in folder
  2. Refer to the example code example/suite.testsuite.example1.js on how to include test libraries and for a sample testuite
  3. For more on syntax of testuite please refer https://mochajs.org/ .Beware, asynchrnous tests are not supported. Also, the reporters are not supported.
  4. For more on syntax of assertions please refer http://chaijs.com/

TODO

  1. Better UI for suitelet :)
  2. Support for SuiteScript 2.0

mochafornetsuite's People

Contributors

flanker avatar prasunsultania avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.