Code Monkey home page Code Monkey logo

better-assert's Introduction

better-assert's People

Contributors

adohe avatar conradkleinespel avatar craftzdog avatar devinrhode2 avatar forbeslindesay avatar kgantsov avatar mikaturunen avatar tj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

better-assert's Issues

better-assert browser version

The issues are closed there so I have to put my doubts here, although not so relevant:

It is unworthy to assert in browsers, considering the overheads in brand-width. It is also not meant for continuous development. I think console.assert is the right way to go.

Browser support

I'm using babel as a part of ember-cli, had to use ember-browserify to be able to import better-assert, but now I get fs.readFileSync is not a function because this is a browser, of course.

This code:

import assert from 'npm:better-assert'

try {
    console.log('before calling assert')
    assert('true')
    console.log('called assert')
    assert(false)
    console.log('called with false')
} catch (e) {
    console.log('caught err'+e.stack)
}

Prints this:

before calling assert
cat.js:7 called assert
cat.js:11 caught errTypeError: fs.readFileSync is not a function
    at assert (http://localhost:4200/assets/vendor.js:65236:16)
    at Module.callback (http://localhost:4200/assets/dynamic-segments.js:385:35)
    at Module.exports (http://localhost:4200/assets/vendor.js:131:32)
    at requireModule (http://localhost:4200/assets/vendor.js:30:18)
    at Class._extractDefaultExport (http://localhost:4200/assets/vendor.js:144697:20)
    at Class.resolveOther (http://localhost:4200/assets/vendor.js:144432:32)
    at Class.superWrapper (http://localhost:4200/assets/vendor.js:35482:22)
    at Class.resolve (http://localhost:4200/assets/vendor.js:16205:43)
    at resolve (http://localhost:4200/assets/vendor.js:12565:36)
    at Object.resolve (http://localhost:4200/assets/vendor.js:12025:21)

Ember goliath generates horrible stack trace! 💯 :)

Going to fork and see what I can do..!

Will not work for multiline expressions

As the regex is configured at the moment, it is not possible to have line breaks in the code that is to be asserted. This could be fixed either by adding a separate method for doing asserts on code with line breaks (if todays behavior is needed), or adapting the regex to accept line breaks.

Is this something that could be fixed?

Assertion error also shows the value of the thing it got instead of what it was expecting?

I like.

Would be cool if it included what it saw in the error message:

- AssertionError: 'number' == typeof user.age.
+ AssertionError: 'number' == typeof user.age. user.age is undefined.
    at test (/Users/tj/projects/better-assert/example.js:9:3)
    at Object.<anonymous> (/Users/tj/projects/better-assert/example.js:4:1)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.runMain (module.js:492:10)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)

string diffs

would be nice to support the string diffs like should.js does. not sure what that involves to get it working with mocha

Error when importing using a different name than "assert"

Basically if you name the assert function other than "assert" the regex fails.

const betterAss = require("./index");
betterAss(1 === 2);
~/better-assert/index.js:30
  var src = line.match(/assert\((.*)\)/)[1];
                                        ^

TypeError: Cannot read property '1' of null
    at assert (~/better-assert/index.js:30:41)
    at Object.<anonymous> (~/better-assert/fn-name-test.js:4:1)

does not work with babel

TypeError: Cannot read property '1' of null

The callsite returns a line number for compiled code but it's trying to read the line from uncompiled one.

Release new version

The current version is 8 commits behind. Furthermore, the newest version of the npm package does not yet include the license (see #11).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.