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

console-fail-test

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

console-fail-test - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

.github/workflows/publish.yml

34

.eslintrc.js
module.exports = {
env: {
browser: true,
es6: true,
},
extends: ["plugin:@typescript-eslint/recommended", "prettier", "prettier/@typescript-eslint"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: "tsconfig.json",
sourceType: "module",
},
plugins: ["@typescript-eslint"],
rules: {
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
},
env: {
browser: true,
es6: true,
},
extends: ["plugin:@typescript-eslint/recommended", "prettier", "prettier/@typescript-eslint"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: "tsconfig.json",
sourceType: "module",
},
plugins: ["@typescript-eslint"],
rules: {
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
},
};
{
"arrowParens": "always",
"parser": "typescript",
"printWidth": 140,
"tabWidth": 4,
"trailingComma": "all",
"overrides": [
{
"files": ".*.json",
"options": {
"parser": "json"
}
},
{
"files": "*.json",
"options": {
"parser": "json"
}
},
{
"files": ".vscode/*.json",
"options": {
"parser": "json"
}
},
{
"files": "*.md",
"options": {
"parser": "markdown"
}
},
{
"files": "*.yml",
"options": {
"parser": "yaml"
}
}
]
"printWidth": 100,
"tabWidth": 2,
"trailingComma": "all"
}
{
"files.exclude": {
"**/*.js": {
"when": "$(basename).ts"
},
"**/*.d.ts": {
"when": "$(basename).ts"
}
"files.exclude": {
"**/*.js": {
"when": "$(basename).ts"
},
"**/*.d.ts": {
"when": "$(basename).ts"
}
}
}

@@ -17,18 +17,18 @@ # Contributor Covenant Code of Conduct

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

@@ -59,3 +59,3 @@ ## Our Responsibilities

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at support@codecademy.com. All
reported by contacting the project team at me@joshuakgoldberg.com. All
complaints will be reviewed and investigated and will result in a response that

@@ -62,0 +62,0 @@ is deemed necessary and appropriate to the circumstances. The project team is

@@ -14,4 +14,4 @@ # AVA

require("console-fail-test").cft({
testFramework: require("ava"),
testFramework: require("ava"),
});
```

@@ -6,3 +6,3 @@ # Development

We'd love to work with you.
Please check for open issues before filing your own; if you'd like to send a pull request, make sure there's an open issue marked [accepting prs](https://github.com/RyzacInc/console-fail-test/labels/accepting%20prs) first.
Please check for open issues before filing your own; if you'd like to send a pull request, make sure there's an open issue marked [accepting prs](https://github.com/JoshuaKGoldberg/console-fail-test/labels/accepting%20prs) first.

@@ -34,6 +34,6 @@ ## Local Setup

1. Find or file an issue tagged with [test framework support](https://github.com/RyzacInc/console-fail-test/issues?q=is%3Aissue+is%3Aopen+label%3A%22test+framework+support%22) and wait until it's marked as [accepting prs](https://github.com/RyzacInc/console-fail-test/labels/accepting%20prs)
1. Find or file an issue tagged with [test framework support](https://github.com/JoshuaKGoldberg/console-fail-test/issues?q=is%3Aissue+is%3Aopen+label%3A%22test+framework+support%22) and wait until it's marked as [accepting prs](https://github.com/JoshuaKGoldberg/console-fail-test/labels/accepting%20prs)
2. Add a new file under [`src/environments`](../src/environments) that exports a function matching `TestEnvironmentGetter`:
- If the environment isn't provided and doesn't seem to exist, return `undefined`
- If the environment is provided or does seem to exist, return an object with hooks to be called by [`cft.ts`](../src/cft.ts)
- If the environment isn't provided and doesn't seem to exist, return `undefined`
- If the environment is provided or does seem to exist, return an object with hooks to be called by [`cft.ts`](../src/cft.ts)
3. Add that getter to `testEnvironmentsByName` and `detectableTestEnvironmentGetters` in [`src/environments/selectTestEnvironment.ts`](../src/environments/selectTestEnvironment.ts)

@@ -53,6 +53,6 @@

1. Find or file an issue tagged with [spy library support](https://github.com/RyzacInc/console-fail-test/issues?q=is%3Aissue+is%3Aopen+label%3A%22spy+library+support%22) and wait until it's marked as [accepting prs](https://github.com/RyzacInc/console-fail-test/labels/accepting%20prs)
1. Find or file an issue tagged with [spy library support](https://github.com/JoshuaKGoldberg/console-fail-test/issues?q=is%3Aissue+is%3Aopen+label%3A%22spy+library+support%22) and wait until it's marked as [accepting prs](https://github.com/JoshuaKGoldberg/console-fail-test/labels/accepting%20prs)
2. Add a new file under [`src/spies`](../src/spies) that exports a function matching matching `SpyFactoryGetter`:
- If the spy library isn't provided and doesn't seem to exist, return `undefined`
- If the spy library is provided or does seem to exist, return a method that, given a container object and method name, spies on that method on the container
- If the spy library isn't provided and doesn't seem to exist, return `undefined`
- If the spy library is provided or does seem to exist, return a method that, given a container object and method name, spies on that method on the container
3. Add that getter to `spyFactoriesByName` and `detectableSpyFactoryGetters` in [src/spies/selectSpyFactory.ts](../src/spies/selectSpyFactory.ts).

@@ -59,0 +59,0 @@

@@ -35,4 +35,4 @@ # Jest

require("console-fail-test").cft({
spyLibrary: "jasmine",
spyLibrary: "jasmine",
});
```

@@ -15,4 +15,4 @@ # lab

require("console-fail-test").cft({
testFramework: exports.lab,
testFramework: exports.lab,
});
```

@@ -14,4 +14,4 @@ # node-tap

require("console-fail-test").cft({
testFramework: require("node-tap"),
testFramework: require("node-tap"),
});
```

@@ -10,3 +10,3 @@ # Sinon

require("console-fail-test").cft({
spyLibrary: require("sinon"),
spyLibrary: require("sinon"),
});

@@ -13,0 +13,0 @@ ```

@@ -1,5 +0,3 @@

MIT License
# MIT License
Copyright (c) 2019 Ryzac, Inc
Permission is hereby granted, free of charge, to any person obtaining a copy

@@ -6,0 +4,0 @@ of this software and associated documentation files (the "Software"), to deal

{
"author": "Codecademy",
"name": "console-fail-test",
"description": "Gently fails test runs if the console was used during them.",
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^3.0.0",
"@typescript-eslint/parser": "^3.0.0",
"eslint": "^7.1.0",
"eslint-config-prettier": "^6.11.0",
"husky": "^4.2.5",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.5",
"pretty-quick": "^2.0.1",
"typescript": "^3.9.3"
},
"main": "src/index.js",
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged --write"
}
},
"keywords": ["console", "fail", "info", "jest", "log", "test", "warn"],
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/Codecademy/console-fail-test.git"
},
"scripts": {
"compile": "tsc",
"lint": "eslint src/**/*.ts",
"prettier:write": "prettier --config .prettierrc.json --write",
"prettier:write:all": "yarn run prettier:write ./{.,src}/**/*.{json,md,ts,yml}",
"verify": "run-s compile lint"
},
"version": "0.1.5",
"dependencies": {}
"author": "Josh Goldberg <me@joshuakgoldberg.com>",
"name": "console-fail-test",
"description": "Gently fails test runs if the console was used during them.",
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^3.0.0",
"@typescript-eslint/parser": "^3.0.0",
"eslint": "^7.1.0",
"eslint-config-prettier": "^6.11.0",
"husky": "^4.2.5",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.5",
"pretty-quick": "^2.0.1",
"typescript": "^3.9.3"
},
"main": "src/index.js",
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged --write"
}
},
"keywords": [
"console",
"fail",
"info",
"jest",
"log",
"test",
"warn"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/JoshuaKGoldberg/console-fail-test.git"
},
"scripts": {
"compile": "tsc",
"format": "yarn prettier --write",
"format:verify": "yarn prettier --list-different \"**/*.{js,json,md,ts,yml}\"",
"format:write-all": "yarn format:verify --write",
"lint": "yarn eslint \"src/**/*.ts\" --max-warnings 0 --report-unused-disable-directives"
},
"version": "0.1.6"
}
# console-fail-test
[![Circle CI](https://circleci.com/gh/Codecademy/console-fail-test.svg?style=svg)](https://circleci.com/gh/Codecademy/console-fail-test)
[![Circle CI](https://circleci.com/gh/JoshuaKGoldberg/console-fail-test.svg?style=svg)](https://circleci.com/gh/JoshuaKGoldberg/console-fail-test)
[![NPM version](https://img.shields.io/npm/v/console-fail-test.svg)](https://npmjs.org/package/console-fail-test)
[![Downloads](http://img.shields.io/npm/dm/console-fail-test.svg)](https://npmjs.org/package/console-fail-test)
[![Greenkeeper](https://badges.greenkeeper.io/Codecademy/console-fail-test.svg)](https://greenkeeper.io/)
[![Join the chat at https://gitter.im/Codecademy/console-fail-test](https://badges.gitter.im/Codecademy/console-fail-test.svg)](https://gitter.im/Codecademy/console-fail-test?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
![Code Style: Prettier](https://img.shields.io/badge/code_style-prettier-14cc21.svg)

@@ -21,4 +19,4 @@

require("console-fail-test").cft({
testFramework: "jest",
spyLibrary: "jasmine",
testFramework: "jest",
spyLibrary: "jasmine",
});

@@ -34,3 +32,3 @@ ```

require("console-fail-test").cft({
testFramework: require("ava"),
testFramework: require("ava"),
});

@@ -143,3 +141,3 @@ ```

<td>
<a href="https://github.com/RyzacInc/console-fail-test/issues/19">
<a href="https://github.com/JoshuaKGoldberg/console-fail-test/issues/19">
<code>/issues/19</code>

@@ -156,3 +154,3 @@ </a>

<td>
<a href="https://github.com/RyzacInc/console-fail-test/issues/17">
<a href="https://github.com/JoshuaKGoldberg/console-fail-test/issues/17">
<code>/issues/17</code>

@@ -169,3 +167,3 @@ </a>

<td>
<a href="https://github.com/RyzacInc/console-fail-test/issues/15">
<a href="https://github.com/JoshuaKGoldberg/console-fail-test/issues/15">
<code>/issues/15</code>

@@ -178,3 +176,3 @@ </a>

> See [open test framework support issues](https://github.com/RyzacInc/console-fail-test/issues?q=is%3Aissue+is%3Aopen+label%3A%22test+framework+support%22) for progress!
> See [open test framework support issues](https://github.com/JoshuaKGoldberg/console-fail-test/issues?q=is%3Aissue+is%3Aopen+label%3A%22test+framework+support%22) for progress!

@@ -189,3 +187,3 @@ ### Spy Libraries

require("console-fail-test").cft({
spyLibrary: "sinon",
spyLibrary: "sinon",
});

@@ -271,5 +269,5 @@ ```

require("console-fail-test").cft({
console: {
warn: true, // won't error on any instance of console.warn
},
console: {
warn: true, // won't error on any instance of console.warn
},
});

@@ -282,5 +280,5 @@ ```

- 🚫 warnings from third-party libraries such as React for improper usage
- 🤕 temporary code that shouldn't be checked into your project
- 📢 unnecessary spam in your tests window
- 🚫 warnings from third-party libraries such as React for improper usage
- 🤕 temporary code that shouldn't be checked into your project
- 📢 unnecessary spam in your tests window

@@ -290,4 +288,4 @@ This little library throws an error after each test if a console method was called during it.

- 📊 Summary of which methods are called with calling arguments
- 🛫 Failures are thrown _after_ tests finish, so your tests will fail normally if they should
- 📊 Summary of which methods are called with calling arguments
- 🛫 Failures are thrown _after_ tests finish, so your tests will fail normally if they should

@@ -302,4 +300,4 @@ Look how fancy the terminal output is with Jest!

- [Node.js](https://nodejs.org) >10 (LTS)
- [Yarn](https://yarnpkg.com/en)
- [Node.js](https://nodejs.org) >10 (LTS)
- [Yarn](https://yarnpkg.com/en)

@@ -320,4 +318,4 @@ After [forking the repo from GitHub](https://help.github.com/articles/fork-a-repo):

We'd love to have you contribute!
Check the [issue tracker](https://github.com/Codecademy/console-fail-test/issues) for issues labeled [`accepting prs`](https://github.com/Codecademy/console-fail-test/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3A%22accepting+prs%22) to find bug fixes and feature requests the community can work on.
If this is your first time working with this code, the [`good first issue`](https://github.com/Codecademy/guidelines/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22+) label indicates good introductory issues.
Check the [issue tracker](https://github.com/JoshuaKGoldberg/console-fail-test/issues) for issues labeled [`accepting prs`](https://github.com/JoshuaKGoldberg/console-fail-test/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3A%22accepting+prs%22) to find bug fixes and feature requests the community can work on.
If this is your first time working with this code, the [`good first issue`](https://github.com/JoshuaKGoldberg/console-fail-test/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22+) label indicates good introductory issues.

@@ -324,0 +322,0 @@ Please note that this project is released with a [Contributor Covenant](https://www.contributor-covenant.org).

@@ -7,3 +7,5 @@ "use strict";

const summary = ` * ${methodName} (${calls.length} call${calls.length === 1 ? "" : "s"})`;
const lines = calls.slice(0, Math.min(calls.length, lineThreshold)).map(exports.formatComplaintLineWithIndex);
const lines = calls
.slice(0, Math.min(calls.length, lineThreshold))
.map(exports.formatComplaintLineWithIndex);
if (calls.length > lineThreshold) {

@@ -30,4 +32,7 @@ lines.push(`...${calls.length - lineThreshold} more`);

error,
methodComplaints: methodsWithCalls.map(([methodName, methodCalls]) => ({ methodName, methodCalls })),
methodComplaints: methodsWithCalls.map(([methodName, methodCalls]) => ({
methodName,
methodCalls,
})),
};
};

@@ -5,17 +5,27 @@ "use strict";

exports.getJestEnvironment = () => {
if (typeof afterEach === "undefined" || typeof beforeEach === "undefined" || typeof jest === "undefined") {
if (typeof afterEach === "undefined" ||
typeof beforeEach === "undefined" ||
typeof jest === "undefined") {
return undefined;
}
/* eslint-disable @typescript-eslint/no-empty-function */
let afterEachCallback = () => { };
let beforeEachCallback = () => { };
/* eslint-enable @typescript-eslint/no-empty-function */
afterEach(() => {
afterEachCallback();
});
beforeEach(() => {
beforeEachCallback();
});
return {
after(callback) {
afterEach(() => {
callback({
reportComplaint({ error }) {
throw error;
},
});
afterEachCallback = () => callback({
reportComplaint({ error }) {
throw error;
},
});
},
before: (callback) => {
beforeEach(callback);
beforeEachCallback = callback;
},

@@ -22,0 +32,0 @@ filterMethodCalls: ({ methodCalls }) => methodCalls,

@@ -7,3 +7,3 @@ "use strict";

// we check the stringified versions of its used hook methods
// See https://github.com/RyzacInc/console-fail-test/issues/10
// See https://github.com/JoshuaKGoldberg/console-fail-test/issues/10
if (typeof afterEach === "undefined" ||

@@ -10,0 +10,0 @@ typeof beforeEach === "undefined" ||

@@ -24,3 +24,3 @@ "use strict";

// Mocha should be last because it's difficult to accurately detect
// See https://github.com/RyzacInc/console-fail-test/issues/10
// See https://github.com/JoshuaKGoldberg/console-fail-test/issues/10
mocha_1.getMochaEnvironment,

@@ -27,0 +27,0 @@ ];

@@ -6,3 +6,4 @@ "use strict";

const isJasmineModule = (spyLibrary) => {
return typeof spyLibrary === "object" && typeof spyLibrary.createSpy === "function";
return (typeof spyLibrary === "object" &&
typeof spyLibrary.createSpy === "function");
};

@@ -13,3 +14,5 @@ const createJasmineSpyFactory = (spyLibrary) => {

const originalMethod = container[methodName];
container[methodName] = spyLibrary.createSpy().and.callFake(function (...args) {
container[methodName] = spyLibrary
.createSpy()
.and.callFake(function (...args) {
methodCalls.push({

@@ -16,0 +19,0 @@ args,

{
"compilerOptions": {
"esModuleInterop": true,
"module": "commonjs",
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true,
"target": "es2015"
}
"compilerOptions": {
"esModuleInterop": true,
"module": "commonjs",
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true,
"target": "es2015"
}
}

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