Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nightwatch/esbuild-utils

Package Overview
Dependencies
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nightwatch/esbuild-utils - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

src/babel.js

6

package.json

@@ -6,3 +6,3 @@ {

},
"version": "0.1.6",
"version": "0.1.7",
"description": "",

@@ -17,4 +17,6 @@ "main": "index.js",

"dependencies": {
"@babel/core": "^7.19.3",
"esbuild": "^0.15.8",
"lodash.merge": "^4.6.2"
"lodash.merge": "^4.6.2",
"lodash.mergewith": "^4.6.2"
},

@@ -21,0 +23,0 @@ "devDependencies": {

const fs = require('fs');
const path = require('path');
const {build, transform} = require('esbuild');
const merge = require('lodash.merge');
const mergeWith = require('lodash.mergewith');
const {pathToFileURL} = require('url');
const babel = require('./babel.js');
const ESBUILD_LOADERS = Object.freeze({
'.js': 'js',
'.js': 'jsx',
'.cjs': 'js',

@@ -89,5 +93,41 @@ '.jsx': 'jsx',

const buildFile = function(modulePath, additionalConfig = {}) {
const config = merge({}, ESBUILD_CONFIG, additionalConfig);
const ESBUILD_CONFIGS = ['esbuild.config.mjs', 'esbuild.config.js'];
async function resolveExternalConfig() {
for (const name of ESBUILD_CONFIGS) {
if (fs.existsSync(name)) {
try {
const {default: values} = await import(pathToFileURL(path.resolve(name)));
return values;
} catch {
continue;
}
}
}
return {};
}
const buildFile = async function(modulePath, additionalConfig = {}) {
const fileConfig = await resolveExternalConfig();
if (additionalConfig.babel) {
additionalConfig.plugins = additionalConfig.plugins || [];
additionalConfig.plugins.push(
babel(typeof additionalConfig.babel === 'boolean' ? {} : additionalConfig.babel)
);
delete additionalConfig.babel;
}
mergeWith(fileConfig, additionalConfig, function customizer(objValue, srcValue) {
if (Array.isArray(objValue)) {
return objValue.concat(srcValue);
}
});
const config = merge({}, ESBUILD_CONFIG, fileConfig);
return build({...config, entryPoints: [modulePath]});

@@ -94,0 +134,0 @@ };

@@ -91,3 +91,3 @@ const path = require('path');

const component = ${exportName === 'default' ? `${path.basename(modulePath, path.extname(modulePath)).replace(/-+/, '_')}_${exportName}` : exportName};
const component = module.exports["${exportName}"];

@@ -98,3 +98,3 @@ if (data.beforeMountError) {

if (component.test) {
if (component && component.test) {
await Promise.resolve(component.test(browser, data));

@@ -128,4 +128,4 @@ }

const component = ${exportName === 'default' ? `${path.basename(modulePath, path.extname(modulePath)).replace(/-+/, '_')}_${exportName}` : exportName};
if (component.test) {
const component = module.exports["${exportName}"];
if (component && component.test) {
return component.test(browser, data);

@@ -180,4 +180,9 @@ }

this.skipTestcasesOnFail = false;
let testNamespace;
try {
componentDefault = ${path.basename(modulePath, path.extname(modulePath)).replace(/[^a-zA-Z0-9]+/g, '_')}_default;
componentDefault = module.exports.default;
if (componentDefault && componentDefault.test) {
testNamespace = componentDefault.test;
}

@@ -187,22 +192,21 @@ before(async function(browser) {

if (typeof componentDefault.before == 'function') {
await componentDefault.before(browser);
if (testNamespace && typeof testNamespace.before == 'function') {
await testNamespace.before(browser);
}
});
if (typeof componentDefault.beforeEach == 'function') {
beforeEach(componentDefault.beforeEach);
if (testNamespace && typeof testNamespace.beforeEach == 'function') {
beforeEach(testNamespace.beforeEach);
}
if (typeof componentDefault.afterEach == 'function') {
afterEach(componentDefault.afterEach);
if (testNamespace && typeof testNamespace.afterEach == 'function') {
afterEach(testNamespace.afterEach);
}
after(async function(browser) {
if (typeof componentDefault.after == 'function') {
after(componentDefault.after);
if (testNamespace && typeof testNamespace.after == 'function') {
after(testNamespace.after);
}
});
} catch (err) {

@@ -209,0 +213,0 @@ console.error('Error:', err);

@@ -57,4 +57,4 @@ const path = require('path');

const data = result === null || result === void 0 ? {} : result;
const component = Primary;
if (component.test) {
const component = module.exports["Primary"];
if (component && component.test) {
return component.test(browser, data);

@@ -101,7 +101,7 @@ }

const data = mountResult || {};
const component = Primary;
const component = module.exports["Primary"];
if (data.beforeMountError) {
console.error(data.beforeMountError.message);
}
if (component.test) {
if (component && component.test) {
await Promise.resolve(component.test(browser, data));

@@ -115,3 +115,35 @@ }

const describeBlock = `describe("Button.stories.jsx component", function() {
let componentDefault;
let cdpConnection;
this.desiredCapabilities.pageLoadStrategy = "eager";
this.skipTestcasesOnFail = false;
let testNamespace;
try {
componentDefault = module.exports.default;
if (componentDefault && componentDefault.test) {
testNamespace = componentDefault.test;
}
before(async function(browser) {
if (testNamespace && typeof testNamespace.before == "function") {
await testNamespace.before(browser);
}
});
if (testNamespace && typeof testNamespace.beforeEach == "function") {
beforeEach(testNamespace.beforeEach);
}
if (testNamespace && typeof testNamespace.afterEach == "function") {
afterEach(testNamespace.afterEach);
}
after(async function(browser) {
if (testNamespace && typeof testNamespace.after == "function") {
after(testNamespace.after);
}
});
} catch (err) {
console.error("Error:", err);
}`;
assert.ok(text.includes(textToMatch));
assert.ok(text.includes(describeBlock));
});

@@ -118,0 +150,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc