Comparing version 3.1.5 to 3.1.7
"use strict"; | ||
var _js = require("../js"); | ||
var _path = require("../path"); | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
@@ -32,2 +33,3 @@ try { | ||
} | ||
// jest.mock('../path'); | ||
const nonPatchedFile = ` | ||
@@ -51,7 +53,7 @@ process.env.CYPRESS_INTERNAL_ENV = | ||
process.env.CYPRESS_INTERNAL_ENV || "production"; | ||
require("./packages/server"); | ||
require('./packages/server'); | ||
`; | ||
const result = `(function ${_js.FN_ID}() { | ||
const result = (path = 'foo')=>`(function ${_js.FN_ID}() { | ||
try { | ||
require('foo'); | ||
require('${path}'); | ||
} catch (e) { | ||
@@ -61,3 +63,4 @@ } | ||
process.env.CYPRESS_INTERNAL_ENV = process.env.CYPRESS_INTERNAL_ENV || 'production'; | ||
require('./packages/server');`; | ||
require('./packages/server');` | ||
; | ||
test('should return false for non-injected code', ()=>{ | ||
@@ -70,6 +73,9 @@ expect((0, _js).hasInjected((0, _js).parseJS(nonPatchedFile))).toEqual(false); | ||
test('should inject new code', _asyncToGenerator(function*() { | ||
expect((0, _js).instrumentCypressInit(nonPatchedFile, 'foo')).toEqual(result); | ||
expect((0, _js).instrumentCypressInit(nonPatchedFile, 'foo')).toEqual(result()); | ||
})); | ||
test('should replace existing code', _asyncToGenerator(function*() { | ||
expect((0, _js).instrumentCypressInit(patchedFile, 'foo')).toEqual(result); | ||
expect((0, _js).instrumentCypressInit(patchedFile, 'foo')).toEqual(result()); | ||
})); | ||
test('should inject new code for windows path', _asyncToGenerator(function*() { | ||
expect((0, _js).instrumentCypressInit(nonPatchedFile, 'C:\\Users\\Administrator\\Desktop\\node_modules\\cy2\\dist/injected.js')).toEqual(result((0, _path).normalizePath('C:\\Users\\Administrator\\Desktop\\node_modules\\cy2\\dist/injected.js'))); | ||
})); |
@@ -10,2 +10,3 @@ "use strict"; | ||
var _estraverse = _interopRequireDefault(require("estraverse")); | ||
var _path = require("./path"); | ||
function _interopRequireDefault(obj) { | ||
@@ -21,5 +22,3 @@ return obj && obj.__esModule ? obj : { | ||
exports.parseJS = parseJS; | ||
const generateJS = (ast)=>_escodegen.default.generate(ast, { | ||
verbatim: 'raw' | ||
}) | ||
const generateJS = (ast)=>_escodegen.default.generate(ast) | ||
; | ||
@@ -30,5 +29,6 @@ exports.generateJS = generateJS; | ||
const instrumentCypressInit = (code, injectedModulePath)=>{ | ||
const normalizedPath = (0, _path).normalizePath(injectedModulePath); | ||
const injectedFn = ` | ||
function ${FN_ID}() { | ||
try { require('${injectedModulePath}'); } | ||
try { require('${normalizedPath}'); } | ||
catch (e) {} | ||
@@ -35,0 +35,0 @@ }`; |
{ | ||
"name": "cy2", | ||
"version": "3.1.5", | ||
"version": "3.1.7", | ||
"author": "Andrew Goldis", | ||
@@ -29,3 +29,4 @@ "main": "./dist", | ||
"js-yaml": "^4.1.0", | ||
"npm-which": "^3.0.1" | ||
"npm-which": "^3.0.1", | ||
"slash": "3.0.0" | ||
}, | ||
@@ -32,0 +33,0 @@ "files": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47142
37
1123
7
+ Addedslash@3.0.0
+ Addedslash@3.0.0(transitive)