npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

suitescript-mocks

v0.3.1

Published

Set of mocks for unit testing Netsuite Suitescript 2.*

Downloads

144

Readme

SuiteScript Mocks

This is a set of mocks for unit testing Netsuite. Modules that don't have a mock written for them instead use a stub from https://github.com/KyleJonesWinsted/suitecloud-unit-testing-stubs.

Setup:

package.json type should not be module

jest.config.js

const SuiteCloudJestConfiguration = require("@oracle/suitecloud-unit-testing/jest-configuration/SuiteCloudJestConfiguration.js");
const { defaults } = require("jest-config");
const SuiteScriptMocks = require("suitescript-mocks");
const cliConfig = require("./suitecloud.config.js");

const config = SuiteCloudJestConfiguration.build({
    projectFolder: cliConfig.defaultProjectFolder,
    projectType: SuiteCloudJestConfiguration.ProjectType.ACP,
    customStubs: SuiteScriptMocks.stubs,
});

module.exports = {
    ...config,
    moduleFileExtensions: [...defaults.moduleFileExtensions, "cjs"],
};

suitecloud.config.js

const SuiteCloudJestUnitTestRunner = require("@oracle/suitecloud-unit-testing/services/SuiteCloudJestUnitTestRunner");

module.exports = {
    defaultProjectFolder: "src",
    commands: {
        "project:deploy": {
            beforeExecuting: async (args) => {
                await SuiteCloudJestUnitTestRunner.run({
                    // Jest configuration options.
                });
                return args;
            },
        },
    },
};

Usage:

The SuiteScriptMocks object exported by default by this package has a number of properties on it that control how the mocks work. | Property | Description | | ------------------- | --------------------------------------------------------------------------------------------------------------------- | | outputDebugLogs | Choose whether or not to output debug logs to the console. | | outputErrorLogs | Choose whether or not to output error logs to the console. | | outputAuditLogs | Choose whether or not to output audit logs to the console. | | currentScript | Details loaded when using runtime.getCurrentScript() | | currentUser | Details loaded when using runtime.getCurrentUser() | | currentSession | Details loaded when using runtime.getCurrentSession() | | features | Map of which netsuite features are enabled, used by runtime.isFeatureInEffect | | sentEmails | List of emails sent using N/email. | | caches | List of caches used by cache.getCache. | | files | List of files used by file.load, etc. Use File constructor when creating files to add to this. | | createdFiles | List of files that have been created. | | savedFiles | List of files that have been saved. | | deletedFiles | List of files that have been deleted. | | records | List of records used by record.load, etc. Use Record constructor when creating records to add to this. | | createdRecords | List of records that have been created. | | savedRecords | List of records that have been saved. | | deletedRecords | List of records that have been deleted. | | searches | List of searches used by search.load, etc. Use Search constructor when creating searches to add to this. | | runSearches | List of searches that have been run. | | searchResults | List of search results consumed by dynamically created and executed searches. | | lookupFieldsResults | List of results consumed by search.lookupFields. | | taskStatuses | List of task statuses used by task.checkStatus. | | submittedTasks | List of submitted tasks. | | logs | List of execution logs created by N/log | | dialogs | List of dialogs created using N/ui/dialog | | dialogResults | List of results consumed by dialog.confirm and dialog.create. | | messages | List of messages created using N/ui/message | | reset | Function used to reset the state of the mocks library. Advisable to do before every test run, likely in a beforeEach. |

For specific examples please look at the tests.