sinonjs / formatio Goto Github PK
View Code? Open in Web Editor NEWThe cheesy object formatter
Home Page: https://sinonjs.github.io/formatio/
License: Other
The cheesy object formatter
Home Page: https://sinonjs.github.io/formatio/
License: Other
What did you expect to happen?
I expected this to work with BigInts just fine. It seems to be the case for most BigInts, except 0n
.
What actually happens
It throws TypeError: Cannot mix BigInt and other types, use explicit conversions
.
How to reproduce
formatio.ascii(0n)
produces this error and stacktrace:
> formatio.ascii(0n)
Thrown:
TypeError: Cannot mix BigInt and other types, use explicit conversions
at ascii (.../node_modules/@sinonjs/formatio/lib/formatio.js:77:37)
at Object.ascii (.../node_modules/@sinonjs/formatio/lib/formatio.js:227:16)
Hi,
I am trying to install Sinon and it is throwing an error.
npm ERR! node v6.10.2
npm ERR! npm v3.10.10
npm ERR! code E404
npm ERR! 404 no such package available : @sinonjs/formatio
npm ERR! 404
npm ERR! 404 '@sinonjs/formatio' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of 'nise'
I tried installing from 4.3.0 to 3.2.1 nothing works. This is happening only from yesterday.
Thanks,
Udaykiran
We understand you have a problem and are in a hurry, but please provide us with some info to make it much more likely for your issue to be understood, worked on and resolved quickly.
What did you expect to happen?
What actually happens
We need the updated version of sinonjs/samsam (3.3.3) as a dependency of formatio because of a need to update lodash version that it uses (sinonjs/samsam#72)
How to reproduce
Describe with code how to reproduce the faulty behaviour,
or link to code on JSBin or similar
In some Node environments the DOM
is not fully implemented. In my case using basicHTML. In this senario the ascii.element
function assumes that the element
being passed in as the argument fully implements NamedNodeMap
and calls the item
method.
What did you expect to happen?
That formatio would check that item
was a method on the attrs
object before calling it.
What actually happens
attrs.items
is called without checking and an error is thrown
How to reproduce
npm install && npm install basichtml --save-dev
demo/index.test.js
require("jsdom-global")();
with require('basichtml').init();
npm run demo
TypeError: attrs.item is not a function
at Function.ascii.element (/Users/david/Documents/work/referee-plugin-dom/node_modules/@sinonjs/formatio/lib/formatio.js:186:22)
at ascii (/Users/david/Documents/work/referee-plugin-dom/node_modules/@sinonjs/formatio/lib/formatio.js:78:50)
at Formatio.ascii (/Users/david/Documents/work/referee-plugin-dom/node_modules/@sinonjs/formatio/lib/formatio.js:227:16)
at format (/Users/david/Documents/work/referee-plugin-dom/node_modules/@sinonjs/referee/lib/format.js:18:28)
at /Users/david/Documents/work/referee-plugin-dom/node_modules/@sinonjs/referee/lib/interpolate-properties.js:21:23
at Array.reduce (<anonymous>)
at interpolateProperties (/Users/david/Documents/work/referee-plugin-dom/node_modules/@sinonjs/referee/lib/interpolate-properties.js:15:12)
at Object.fail (/Users/david/Documents/work/referee-plugin-dom/node_modules/@sinonjs/referee/lib/define-assertion.js:32:27)
at assertion (/Users/david/Documents/work/referee-plugin-dom/node_modules/@sinonjs/referee/lib/define-assertion.js:68:17)
at Function.referee.(anonymous function).(anonymous function) [as tagName] (/Users/david/Documents/work/referee-plugin-dom/node_modules/@sinonjs/referee/lib/define-assertion.js:93:26)
at Context.<anonymous> (/Users/david/Documents/work/referee-plugin-dom/demo/basic-html.test.js:37:32)
at callFn (/Users/david/Documents/work/referee-plugin-dom/node_modules/mocha/lib/runnable.js:387:21)
at Test.Runnable.run (/Users/david/Documents/work/referee-plugin-dom/node_modules/mocha/lib/runnable.js:379:7)
at Runner.runTest (/Users/david/Documents/work/referee-plugin-dom/node_modules/mocha/lib/runner.js:525:10)
at /Users/david/Documents/work/referee-plugin-dom/node_modules/mocha/lib/runner.js:643:12
at next (/Users/david/Documents/work/referee-plugin-dom/node_modules/mocha/lib/runner.js:437:14)
at /Users/david/Documents/work/referee-plugin-dom/node_modules/mocha/lib/runner.js:447:7
at next (/Users/david/Documents/work/referee-plugin-dom/node_modules/mocha/lib/runner.js:362:14)
at Immediate.<anonymous> (/Users/david/Documents/work/referee-plugin-dom/node_modules/mocha/lib/runner.js:415:5)
at runCallback (timers.js:794:20)
at tryOnImmediate (timers.js:752:5)
at processImmediate [as _immediateCallback] (timers.js:729:5)
Calling sinon.assert.calledWith fails, if the stub was called with an object having a toString method which throws.
How to reproduce
it('shall reproduce formatio bug', function () {
const poison = {
toString: () => {
throw new Error("Boom");
}
};
const myStub = sinon.stub();
myStub(poison);
sinon.assert.calledWith(myStub, "42");
});
Expectation is to see a sinon error message like "expected stub to be called with..." instead of a formatio error.
I think a try/catch and swallow the error should be sufficient.
What did you expect to happen?
formatio.constructorName(Object.create(null, {}))
returns an empty string.
What actually happens
It throws an error: TypeError: Cannot read property 'displayName' of undefined
How to reproduce
const formatio = require('@sinonjs/formatio');
console.log(formatio.constructorName(Object.create(null, {})));
At 3.1.0, constructorName
returned an empty string if an argument didn't have a constructor, but now it throws an error.
We faced this issue when we used sinon and should-sinon. Here is a snippet to reproduce the original issue we had.
const sinon = require('sinon');
require('should-sinon');
const stub = sinon.stub().returns();
const o = Object.create(null, {});
stub(o);
stub.should.be.calledWithExactly(o);
With 3.1.0, this snippet runs without errors, but with 3.1.1 it throws an error: TypeError: Cannot read property 'displayName' of undefined
.
mocha
and referee
mocha
nyc
for test coverage.editorconfig
eslint-config-sinon
eslint-plugin-ie11
eslint-plugin-mocha
lint-staged
and husky
for pre-commit hookMkDocs
and publish to GitHub Pages.github/stale.yml
and create pinned
and stale
labelsmaster
branch from force pushes, including for administrators.npmignore
/ files
section and filter out files that package consumers would not want@sinonjs
scope with a new MAJOR versionA declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.