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

babel-plugin-tester

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-tester - npm Package Compare versions

Comparing version 6.0.0 to 6.0.1

186

dist/__tests__/index.js

@@ -25,15 +25,53 @@ "use strict";

var errorSpy, describeSpy, itSpy, itOnlySpy, itSkipSpy, equalSpy, transformSpy, writeFileSyncSpy;
var errorSpy, describeSpy, itSpy, itOnlySpy, itSkipSpy, equalSpy, transformSpy, writeFileSyncSpy, pendingTests;
var noop = function noop() {};
var noop = function noop() {}; // eslint-disable-next-line require-await
var promiseWrap =
/*#__PURE__*/
function () {
var _ref = _asyncToGenerator(function* (fn) {
return fn();
});
return function promiseWrap(_x) {
return _ref.apply(this, arguments);
};
}();
var describeMock = function describeMock(title, body) {
body();
};
var titleTesterMock = function titleTesterMock(title, testFn) {
return testFn();
pendingTests.push(promiseWrap(testFn));
};
var simpleTest = 'var hi = "hey";';
var runPluginTester =
/*#__PURE__*/
function () {
var _ref2 = _asyncToGenerator(function* () {
pendingTests = [];
try {
_.default.apply(void 0, arguments);
return yield Promise.all(pendingTests);
} finally {
pendingTests = [];
}
});
return function runPluginTester() {
return _ref2.apply(this, arguments);
};
}();
beforeEach(function () {
equalSpy = jest.spyOn(_assert.default, 'equal');
errorSpy = jest.spyOn(console, 'error').mockImplementation(noop);
describeSpy = jest.spyOn(global, 'describe').mockImplementation(titleTesterMock);
describeSpy = jest.spyOn(global, 'describe').mockImplementation(describeMock);
itSpy = jest.spyOn(global, 'it').mockImplementation(titleTesterMock);

@@ -56,28 +94,28 @@ global.it.only = jest.fn(titleTesterMock);

});
test('plugin is required', function () {
expect(function () {
return (0, _.default)();
}).toThrowErrorMatchingSnapshot();
});
test('logs when plugin name is not inferable and rethrows errors', function () {
test('plugin is required',
/*#__PURE__*/
_asyncToGenerator(function* () {
yield expect(runPluginTester()).rejects.toThrowErrorMatchingSnapshot();
}));
test('logs when plugin name is not inferable and rethrows errors',
/*#__PURE__*/
_asyncToGenerator(function* () {
var error = new Error('hey there');
expect(function () {
return (0, _.default)({
plugin: function plugin() {
throw error;
}
});
}).toThrow(error);
yield expect(runPluginTester({
plugin: function plugin() {
throw error;
}
})).rejects.toThrow(error);
expect(errorSpy).toHaveBeenCalledTimes(1);
expect(errorSpy).toHaveBeenCalledWith(expect.stringMatching(/infer.*name.*plugin/));
});
test('throws an invariant if the plugin name is not inferable', function () {
expect(function () {
return (0, _.default)({
plugin: function plugin() {
return {};
}
});
}).toThrowErrorMatchingSnapshot();
});
}));
test('throws an invariant if the plugin name is not inferable',
/*#__PURE__*/
_asyncToGenerator(function* () {
yield expect(runPluginTester({
plugin: function plugin() {
return {};
}
})).rejects.toThrowErrorMatchingSnapshot();
}));
test('exists early if no tests are supplied',

@@ -89,3 +127,3 @@ /*#__PURE__*/

yield (0, _.default)({
yield runPluginTester({
plugin

@@ -102,3 +140,3 @@ });

yield (0, _.default)({
yield runPluginTester({
plugin,

@@ -114,3 +152,3 @@ tests: []

var title = 'describe block title';
yield (0, _.default)(getOptions({
yield runPluginTester(getOptions({
title

@@ -136,3 +174,3 @@ }));

yield (0, _.default)({
yield runPluginTester({
plugin,

@@ -156,3 +194,3 @@ tests

});
yield (0, _.default)(options);
yield runPluginTester(options);
expect(describeSpy).toHaveBeenCalledTimes(1);

@@ -169,3 +207,3 @@ expect(describeSpy).toHaveBeenCalledWith(options.pluginName, expect.any(Function));

yield (0, _.default)({
yield runPluginTester({
plugin,

@@ -186,3 +224,3 @@ tests: [{

yield (0, _.default)({
yield runPluginTester({
plugin,

@@ -197,17 +235,17 @@ tests: [{

}));
test('tests cannot be both only-ed and skipped', function () {
test('tests cannot be both only-ed and skipped',
/*#__PURE__*/
_asyncToGenerator(function* () {
var _getOptions6 = getOptions(),
plugin = _getOptions6.plugin;
expect(function () {
return (0, _.default)({
plugin,
tests: [{
only: true,
skip: true,
code: '"hey";'
}]
});
}).toThrowErrorMatchingSnapshot();
});
yield expect(runPluginTester({
plugin,
tests: [{
only: true,
skip: true,
code: '"hey";'
}]
})).rejects.toThrowErrorMatchingSnapshot();
}));
test('default will throw if output changes',

@@ -227,3 +265,3 @@ /*#__PURE__*/

var tests = [simpleTest, undefined, null, simpleTest];
yield (0, _.default)(getOptions({
yield runPluginTester(getOptions({
tests

@@ -263,3 +301,3 @@ }));

}];
yield (0, _.default)(getOptions({
yield runPluginTester(getOptions({
tests

@@ -279,3 +317,3 @@ }));

try {
yield (0, _.default)(getOptions({
yield runPluginTester(getOptions({
plugin: function plugin() {

@@ -310,3 +348,3 @@ return {

try {
yield (0, _.default)(getOptions({
yield runPluginTester(getOptions({
tests

@@ -332,3 +370,3 @@ }));

}];
yield (0, _.default)(getOptions({
yield runPluginTester(getOptions({
tests

@@ -357,3 +395,3 @@ }));

try {
yield (0, _.default)(getOptions({
yield runPluginTester(getOptions({
filename: __filename,

@@ -376,3 +414,3 @@ tests

_asyncToGenerator(function* () {
yield (0, _.default)(getOptions({
yield runPluginTester(getOptions({
filename: __filename,

@@ -390,3 +428,3 @@ fixtures: 'fixtures/fixtures',

try {
yield (0, _.default)(getOptions({
yield runPluginTester(getOptions({
plugin: _identifierReversePlugin.default,

@@ -403,3 +441,3 @@ tests: null,

_asyncToGenerator(function* () {
yield (0, _.default)(getOptions({
yield runPluginTester(getOptions({
filename: __filename,

@@ -419,3 +457,3 @@ fixtures: 'fixtures/fixtures',

}];
yield (0, _.default)(getOptions({
yield runPluginTester(getOptions({
tests

@@ -439,3 +477,3 @@ }));

}];
yield (0, _.default)(getOptions({
yield runPluginTester(getOptions({
tests

@@ -458,3 +496,3 @@ }));

}];
yield (0, _.default)(getOptions({
yield runPluginTester(getOptions({
tests

@@ -474,3 +512,3 @@ }));

};
yield (0, _.default)(getOptions({
yield runPluginTester(getOptions({
tests,

@@ -496,3 +534,3 @@ pluginOptions

}];
yield (0, _.default)(getOptions({
yield runPluginTester(getOptions({
tests,

@@ -551,3 +589,3 @@ pluginOptions: {

var tests = [simpleTest];
yield (0, _.default)(getOptions({
yield runPluginTester(getOptions({
snapshot: true,

@@ -569,3 +607,3 @@ tests,

};
yield (0, _.default)(getOptions({
yield runPluginTester(getOptions({
tests

@@ -612,3 +650,3 @@ }));

try {
yield (0, _.default)(getOptions({
yield runPluginTester(getOptions({
tests: [`][fkfhgo]fo{r`],

@@ -643,3 +681,3 @@ babelOptions: {

}];
yield (0, _.default)(getOptions({
yield runPluginTester(getOptions({
tests

@@ -657,3 +695,3 @@ }));

}];
yield (0, _.default)(getOptions({
yield runPluginTester(getOptions({
tests

@@ -674,3 +712,3 @@ }));

}];
yield (0, _.default)(getOptions({
yield runPluginTester(getOptions({
tests

@@ -691,3 +729,3 @@ }));

}];
yield (0, _.default)(getOptions({
yield runPluginTester(getOptions({
tests

@@ -708,3 +746,3 @@ }));

}];
var errorThrown = yield (0, _.default)(getOptions({
var errorThrown = yield runPluginTester(getOptions({
tests

@@ -728,3 +766,3 @@ })).catch(function (e) {

}];
var errorThrown = yield (0, _.default)(getOptions({
var errorThrown = yield runPluginTester(getOptions({
tests

@@ -743,3 +781,3 @@ })).catch(function (e) {

});
yield (0, _.default)(getOptions({
yield runPluginTester(getOptions({
tests: [{

@@ -777,3 +815,3 @@ code: simpleTest,

function snapshotOptionsError(_x) {
function snapshotOptionsError(_x2) {
return _snapshotOptionsError.apply(this, arguments);

@@ -787,3 +825,3 @@ }

try {
yield (0, _.default)(options);
yield runPluginTester(options);
} catch (e) {

@@ -798,3 +836,3 @@ error = e;

function snapshotPluginError(_x2, _x3) {
function snapshotPluginError(_x3, _x4) {
return _snapshotPluginError.apply(this, arguments);

@@ -819,3 +857,3 @@ }

function testPluginError(error, overrides) {
return (0, _.default)(getOptions(_objectSpread({
return runPluginTester(getOptions(_objectSpread({
plugin: function plugin() {

@@ -822,0 +860,0 @@ throw new SyntaxError('test message');

@@ -81,10 +81,10 @@ "use strict";

if (!testAsArray.length) {
return Promise.resolve();
return;
}
var testerConfig = (0, _lodash.default)({}, fullDefaultConfig, rest);
return describe(describeBlockTitle, function () {
var promises = testAsArray.map(function (testConfig) {
describe(describeBlockTitle, function () {
testAsArray.forEach(function (testConfig) {
if (!testConfig) {
return Promise.resolve();
return;
}

@@ -113,8 +113,8 @@

// eslint-disable-next-line jest/no-disabled-tests
return it.skip(title, testerWrapper);
it.skip(title, testerWrapper);
} else if (only) {
// eslint-disable-next-line jest/no-focused-tests
return it.only(title, testerWrapper);
it.only(title, testerWrapper);
} else {
return it(title, testerWrapper);
it(title, testerWrapper);
}

@@ -203,3 +203,2 @@

});
return Promise.all(promises);
});

@@ -206,0 +205,0 @@

@@ -1,1 +0,1 @@

{"name":"babel-plugin-tester","version":"6.0.0","description":"Utilities for testing babel plugins","main":"dist/index.js","engines":{"node":"> 4","npm":"> 3"},"scripts":{"add-contributor":"kcd-scripts contributors add","build":"kcd-scripts build","lint":"kcd-scripts lint","test":"kcd-scripts test","test:update":"npm test -- --updateSnapshot --coverage","validate":"kcd-scripts validate","precommit":"kcd-scripts pre-commit"},"files":["dist"],"keywords":[],"author":"Kent C. Dodds <kent@doddsfamily.us> (http://kentcdodds.com/)","license":"MIT","dependencies":{"common-tags":"^1.4.0","invariant":"^2.2.2","lodash.merge":"^4.6.0","path-exists":"^3.0.0","strip-indent":"^2.0.0"},"devDependencies":{"@babel/core":"^7.2.0","@babel/plugin-proposal-async-generator-functions":"^7.2.0","@babel/plugin-transform-async-to-generator":"^7.2.0","@babel/preset-env":"^7.2.0","kcd-scripts":"^0.49.0"},"peerDependencies":{"@babel/core":"^7.0.0"},"eslintConfig":{"extends":"./node_modules/kcd-scripts/eslint.js","rules":{"max-lines":0,"max-lines-per-function":0,"prefer-object-spread":0,"no-useless-catch":0,"babel/camelcase":0,"babel/valid-typeof":0,"babel/no-unused-expressions":0,"babel/quotes":0,"jest/prefer-todo":0}},"eslintIgnore":["node_modules","coverage","dist","fixtures"],"babel":{"presets":[["@babel/preset-env",{"targets":{"node":"4.5"},"exclude":["transform-regenerator"]}]],"plugins":["@babel/plugin-transform-async-to-generator","@babel/plugin-proposal-async-generator-functions","@babel/plugin-proposal-object-rest-spread"]},"prettier":{"printWidth":80,"bracketSpacing":false,"semi":false,"singleQuote":true,"trailingComma":"all"},"repository":{"type":"git","url":"https://github.com/babel-utils/babel-plugin-tester.git"},"bugs":{"url":"https://github.com/babel-utils/babel-plugin-tester/issues"},"homepage":"https://github.com/babel-utils/babel-plugin-tester#readme"}
{"name":"babel-plugin-tester","version":"6.0.1","description":"Utilities for testing babel plugins","main":"dist/index.js","engines":{"node":"> 4","npm":"> 3"},"scripts":{"add-contributor":"kcd-scripts contributors add","build":"kcd-scripts build","lint":"kcd-scripts lint","test":"kcd-scripts test","test:update":"npm test -- --updateSnapshot --coverage","validate":"kcd-scripts validate","precommit":"kcd-scripts pre-commit"},"files":["dist"],"keywords":[],"author":"Kent C. Dodds <kent@doddsfamily.us> (http://kentcdodds.com/)","license":"MIT","dependencies":{"common-tags":"^1.4.0","invariant":"^2.2.2","lodash.merge":"^4.6.0","path-exists":"^3.0.0","strip-indent":"^2.0.0"},"devDependencies":{"@babel/core":"^7.2.0","@babel/plugin-proposal-async-generator-functions":"^7.2.0","@babel/plugin-transform-async-to-generator":"^7.2.0","@babel/preset-env":"^7.2.0","kcd-scripts":"^0.49.0"},"peerDependencies":{"@babel/core":"^7.0.0"},"eslintConfig":{"extends":"./node_modules/kcd-scripts/eslint.js","rules":{"max-lines":0,"max-lines-per-function":0,"prefer-object-spread":0,"no-useless-catch":0,"babel/camelcase":0,"babel/valid-typeof":0,"babel/no-unused-expressions":0,"babel/quotes":0,"jest/prefer-todo":0}},"eslintIgnore":["node_modules","coverage","dist","fixtures"],"babel":{"presets":[["@babel/preset-env",{"targets":{"node":"4.5"},"exclude":["transform-regenerator"]}]],"plugins":["@babel/plugin-transform-async-to-generator","@babel/plugin-proposal-async-generator-functions","@babel/plugin-proposal-object-rest-spread"]},"prettier":{"printWidth":80,"bracketSpacing":false,"semi":false,"singleQuote":true,"trailingComma":"all"},"repository":{"type":"git","url":"https://github.com/babel-utils/babel-plugin-tester.git"},"bugs":{"url":"https://github.com/babel-utils/babel-plugin-tester/issues"},"homepage":"https://github.com/babel-utils/babel-plugin-tester#readme"}

@@ -12,3 +12,3 @@ # babel-plugin-tester

[![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors)
[![All Contributors](https://img.shields.io/badge/all_contributors-6-orange.svg?style=flat-square)](#contributors)
[![PRs Welcome][prs-badge]][prs]

@@ -53,3 +53,2 @@ [![Donate][donate-badge]][donate]

## Installation

@@ -469,4 +468,4 @@

<!-- prettier-ignore -->
| [<img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;"/><br /><sub><b>Kent C. Dodds</b></sub>](https://kentcdodds.com)<br />[💻](https://github.com/babel-utils/babel-plugin-tester/commits?author=kentcdodds "Code") [📖](https://github.com/babel-utils/babel-plugin-tester/commits?author=kentcdodds "Documentation") [🚇](#infra-kentcdodds "Infrastructure (Hosting, Build-Tools, etc)") [⚠️](https://github.com/babel-utils/babel-plugin-tester/commits?author=kentcdodds "Tests") | [<img src="https://avatars3.githubusercontent.com/u/952783?v=3" width="100px;"/><br /><sub><b>james kyle</b></sub>](http://thejameskyle.com/)<br />[💻](https://github.com/babel-utils/babel-plugin-tester/commits?author=thejameskyle "Code") [📖](https://github.com/babel-utils/babel-plugin-tester/commits?author=thejameskyle "Documentation") [👀](#review-thejameskyle "Reviewed Pull Requests") [⚠️](https://github.com/babel-utils/babel-plugin-tester/commits?author=thejameskyle "Tests") | [<img src="https://avatars1.githubusercontent.com/u/1894628?v=3" width="100px;"/><br /><sub><b>Brad Bohen</b></sub>](https://github.com/bbohen)<br />[🐛](https://github.com/babel-utils/babel-plugin-tester/issues?q=author%3Abbohen "Bug reports") | [<img src="https://avatars0.githubusercontent.com/u/1295580?v=3" width="100px;"/><br /><sub><b>Kyle Welch</b></sub>](http://www.krwelch.com)<br />[💻](https://github.com/babel-utils/babel-plugin-tester/commits?author=kwelch "Code") [📖](https://github.com/babel-utils/babel-plugin-tester/commits?author=kwelch "Documentation") [⚠️](https://github.com/babel-utils/babel-plugin-tester/commits?author=kwelch "Tests") | [<img src="https://avatars3.githubusercontent.com/u/6680299?v=4" width="100px;"/><br /><sub><b>kontrollanten</b></sub>](https://github.com/kontrollanten)<br />[💻](https://github.com/babel-utils/babel-plugin-tester/commits?author=kontrollanten "Code") |
| :---: | :---: | :---: | :---: | :---: |
| [<img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;" alt="Kent C. Dodds"/><br /><sub><b>Kent C. Dodds</b></sub>](https://kentcdodds.com)<br />[💻](https://github.com/babel-utils/babel-plugin-tester/commits?author=kentcdodds "Code") [📖](https://github.com/babel-utils/babel-plugin-tester/commits?author=kentcdodds "Documentation") [🚇](#infra-kentcdodds "Infrastructure (Hosting, Build-Tools, etc)") [⚠️](https://github.com/babel-utils/babel-plugin-tester/commits?author=kentcdodds "Tests") | [<img src="https://avatars3.githubusercontent.com/u/952783?v=3" width="100px;" alt="james kyle"/><br /><sub><b>james kyle</b></sub>](http://thejameskyle.com/)<br />[💻](https://github.com/babel-utils/babel-plugin-tester/commits?author=thejameskyle "Code") [📖](https://github.com/babel-utils/babel-plugin-tester/commits?author=thejameskyle "Documentation") [👀](#review-thejameskyle "Reviewed Pull Requests") [⚠️](https://github.com/babel-utils/babel-plugin-tester/commits?author=thejameskyle "Tests") | [<img src="https://avatars1.githubusercontent.com/u/1894628?v=3" width="100px;" alt="Brad Bohen"/><br /><sub><b>Brad Bohen</b></sub>](https://github.com/bbohen)<br />[🐛](https://github.com/babel-utils/babel-plugin-tester/issues?q=author%3Abbohen "Bug reports") | [<img src="https://avatars0.githubusercontent.com/u/1295580?v=3" width="100px;" alt="Kyle Welch"/><br /><sub><b>Kyle Welch</b></sub>](http://www.krwelch.com)<br />[💻](https://github.com/babel-utils/babel-plugin-tester/commits?author=kwelch "Code") [📖](https://github.com/babel-utils/babel-plugin-tester/commits?author=kwelch "Documentation") [⚠️](https://github.com/babel-utils/babel-plugin-tester/commits?author=kwelch "Tests") | [<img src="https://avatars3.githubusercontent.com/u/6680299?v=4" width="100px;" alt="kontrollanten"/><br /><sub><b>kontrollanten</b></sub>](https://github.com/kontrollanten)<br />[💻](https://github.com/babel-utils/babel-plugin-tester/commits?author=kontrollanten "Code") | [<img src="https://avatars3.githubusercontent.com/u/117921?v=4" width="100px;" alt="Rubén Norte"/><br /><sub><b>Rubén Norte</b></sub>](https://github.com/rubennorte)<br />[💻](https://github.com/babel-utils/babel-plugin-tester/commits?author=rubennorte "Code") [⚠️](https://github.com/babel-utils/babel-plugin-tester/commits?author=rubennorte "Tests") |
| :---: | :---: | :---: | :---: | :---: | :---: |

@@ -473,0 +472,0 @@ <!-- ALL-CONTRIBUTORS-LIST:END -->

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