Skip to content

Commit c2e1c6f

Browse files
committed
➕ use minified gives control over which and where to load modules
1 parent 2a6fc23 commit c2e1c6f

5 files changed

Lines changed: 33 additions & 19 deletions

File tree

jest.config.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,19 @@ const CustomJestStubs = require('@vnetwork-solutions/ns-custom-stubs-template/cu
1515
const SuiteCloudJestCustomStubs = SuiteCloudJestStubs.customStubs;
1616
// Add your custom stubs to SuiteCloudJestStubs
1717
const MyCustomStubs = CustomJestStubs.customStubs;
18+
/**
19+
* @typedef UseMinified
20+
* @type {Object}
21+
* @description Options for loading minified file
22+
* @property {boolean} value - T/F do you want to use a minified version in define statement
23+
* @property {String} minName='.min' - Optional alternative post fix identifier to add to file
24+
*/
1825
/**
1926
* @typedef ExcludeStub
2027
* @type {Object}
2128
* @property {String} name - "Directory/Path/ModuleName" -- CustomStub property to use
2229
* @property {String} path - Path to module for project -- generally you will use `\`${__dirname}/src/FileCabinet\``
30+
* @property {UseMinified} useMinified - Options for using or not using minified files locally
2331
* @description Array of module names and paths to use for them in the stubs package
2432
* @summary Here, you can control the paths for stubbed modules to their local file for Jest tests.
2533
*/
@@ -32,10 +40,9 @@ const ExcludeStubs = [
3240
{
3341
name: '/SuiteScripts/Modules/aModule',
3442
path: `${__dirname}/src/FileCabinet`,
35-
},
36-
{
37-
name: '/SuiteScripts/Modules/aModule.min',
38-
path: `${__dirname}/src/FileCabinet`,
43+
useMinified: {
44+
value: false,
45+
},
3946
},
4047
];
4148

@@ -54,6 +61,12 @@ const BuildJestConfig = SuiteCloudJestConfiguration.build({
5461
'(/__tests__/.*|(\\.|/)(test|spec))\\.[jt]sx?$',
5562
'**.*\\.min\\.*',
5663
],
64+
collectCoverageFrom: [
65+
'**/*.{js,jsx}',
66+
'!**/node_modules/**',
67+
'!**/__tests__/**',
68+
'!**/**min.js',
69+
],
5770
});
5871

5972
module.exports = BuildJestConfig;

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "netsuite-custommodules-template",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"description": "NS Template project for testing and using CI/CD for your NetSuite SuiteCloud projects.",
55
"scripts": {
66
"test": "jest --coverage --$npm_config_watch ",
@@ -42,7 +42,7 @@
4242
"homepage": "https://github.com/devnetkc/NetSuite-CustomModules-Template#readme",
4343
"devDependencies": {
4444
"@oracle/suitecloud-unit-testing": "^1.2.1",
45-
"@vnetwork-solutions/ns-custom-stubs-template": "^1.2.0",
45+
"@vnetwork-solutions/ns-custom-stubs-template": "^2.0.1",
4646
"contributor-table": "^1.0.0",
4747
"jest": "^29.3.1",
4848
"jest-junit-reporter": "^1.1.0",

src/FileCabinet/SuiteScripts/CS/customModule_CS.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
];
2626
//AMD & CommonJS compatibility stuff
2727
// CommonJS
28-
/* istanbul ignore next */
28+
/* istanbul ignore else */
2929
if (typeof module !== 'undefined' && typeof require !== 'undefined') {
3030
// Set ID for identifying in Jest
3131
module.id = '/SuiteScripts/CS/csExampleModule_CS';

src/FileCabinet/SuiteScripts/Modules/aModule.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@
2121
const Dependencies = ['N/query', 'N/log'];
2222
//AMD & CommonJS compatibility stuff
2323
// CommonJS
24-
/* istanbul ignore next */
24+
/* istanbul ignore else */
2525
if (typeof module !== 'undefined' && typeof require !== 'undefined') {
2626
// Set ID for identifying in Jest
2727
module.id = '/SuiteScripts/Modules/aModule';
2828
module.exports = aModule.apply(this, Dependencies.map(require));
2929
module.exports.mockable = aModule; // module loader with mockable dependencies
3030
}
31-
// AMD /* istanbul ignore next */
31+
// AMD
32+
/* istanbul ignore next */
3233
if (typeof define !== 'undefined') {
3334
/* istanbul ignore next */
3435
define(Dependencies, aModule);
@@ -71,7 +72,7 @@ function aModule(query, log) {
7172
return QueryResult.prefix;
7273
};
7374
// * This is for Jest to have direct access to all methods for running tests
74-
/* istanbul ignore next */
75+
/* istanbul ignore else */
7576
if (typeof module !== 'undefined' && typeof require !== 'undefined') {
7677
return {
7778
GetVendorPrefix,

0 commit comments

Comments
 (0)