Testing Extensions on a Local Server in NetSuite

Test your extensions on a local server before deployment with Gulp.js, ensuring seamless integration and functionality.

·3 min read·View Oracle Docs

You can test your extension customizations on a local server before deploying to NetSuite. This local server is installed as part of the Node.js setup and utilizes the Express web framework.

Setting Up Your Local Server

To start testing your extension locally, execute the following command in your terminal:

bash
gulp extension:local

This command compiles all source files and places them into the combined files located within the LocalDistribution/tmp directory. When the server starts, Gulp.js initializes watch tasks that monitor changes made to your files, such as JavaScript, Templates, or Sass directories. As you save changes, Gulp automatically recompiles the necessary files and updates the LocalDistribution directory, while also notifying you in the console of any changes.

Important: Typically, you should test your code locally before deployment to a live NetSuite account. However, if your extension includes SuiteScript or configuration files (JSON), you must deploy these files to your account and activate the extension for local server access to them. Services added through SuiteScript won’t be available in your account's backend until deployed, and changes to configuration JSON files require deployment to apply.

Steps to Test Your Extension

Follow these steps to test your extension on a local server:

  1. Fetch the Active Theme: Ensure you fetch the active theme before testing your extension. This is crucial for proper functionality. Refer to the Fetch Active Theme and Extension Files for detailed instructions.

  2. Open Command Line: Access the top-level development directory created after extracting the Extension Developer Tools.

  3. Run Gulp Command: Execute:

    bash
    gulp extension:local

    This initializes your local server and compiles your source files for the first time, creating a LocalDistribution subdirectory if it doesn't already exist.

    Warning: Running gulp extension:local will overwrite your manifest.json file with default changes. To avoid data loss, use the command:

    bash
    gulp extension:local --preserve-manifest

    …to keep your manual modifications intact.

  4. Access Local Application: Navigate to your local application using one of the following URL patterns, ensuring you replace placeholders appropriately:

    • Shopping: http://<_DOMAIN_NAME_>/c.<_ACCOUNT_ID_>/<_SSP_APPLICATION_>/shopping-local.ssp

    • My Account: http://<_DOMAIN_NAME_>/c.<_ACCOUNT_ID_>/_SSP_APPLICATION_/my_account-local.ssp

    • Checkout: http://<_DOMAIN_NAME_>/c.<_ACCOUNT_ID_>/_SSP_APPLICATION_/checkout-local.ssp

    • Example for SuiteCommerce:

      • http://www.mysite.com/c.123456/scs/shopping-local.ssp
    • Example for SuiteCommerce Advanced:

      • http://www.mysite.com/c.123456/sca-dev-aconcagua/shopping-local.ssp

Note: For secure HTTPS checkout access, refer to Secure HTTP (HTTPS) with the Local Server for specifics.

Conclusion

By following these steps, you can effectively test and debug your extension on a local server, ensuring that it functions correctly before deploying it to a live environment. Always be mindful of potential data loss when updating manifest files.

Source: This article is based on Oracle's official NetSuite documentation.

Key Takeaways

  • Test extensions locally to validate functionality before deployment.
  • Use Gulp.js to compile and manage code changes effectively.
  • Ensure you fetch the active theme and deploy your extension correctly to access all features.

Frequently Asked Questions (4)

What command should I use to test my NetSuite extension locally?
You should use the command `gulp extension:local` to start testing your extension on a local server. This will compile all source files and place them into the `LocalDistribution/tmp` directory while monitoring for any file changes.
How can I preserve manual changes in my manifest.json file when testing locally?
To preserve manual changes in your manifest.json file while testing, use the command `gulp extension:local --preserve-manifest` instead of the default `gulp extension:local`.
Do I need to deploy SuiteScript files to test them locally?
Yes, if your extension includes SuiteScript or configuration files, you must deploy these to your NetSuite account and activate the extension to access them during local testing.
What is important to do before testing an extension locally on NetSuite?
Before testing your extension locally, you must fetch the active theme to ensure proper functionality. This is a crucial step for successful testing.
Source: Test an Extension on a Local Server Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in Commerce

View all Commerce articles →