Giter Club home page Giter Club logo

testy's Introduction

Testy

ci
maintainability tech-debt coverage Mutation testing badge
Maintainability Rating Technical Debt Reliability Rating Security Rating
GitHub Repo stars open-issues closed-issues open-prs
downloads dependencies
package-size activity release-date \

all-contributors

A very simple JS testing framework, for educational purposes. Live at npm at @pmoo/testy.

➡️ Documentación en español aquí 👷 Contributing guidelines

Sponsors

10Pines logo

Getting started

npm install --save-dev @pmoo/testy (if you use npm)
yarn add --dev @pmoo/testy (if you use yarn)

Supported Node versions: 18.x or higher (versions with active and security support listed here)

Usage

Writing test suites

A test suite is a file ending _test.js that looks like this:

// my_test.js
import { suite, test, assert } from "@pmoo/testy";

suite("a boring test suite", () => {
  test("42 is 42, not surprising", () => {
    assert.that(42).isEqualTo(42);
  });
});

A test suite represents a grouping of tests, and it is implemented as a function call to suite passing a name and a zero-argument function, which is the suite body.

A test is implemented as a function call to test(), passing a name and the test body as a zero-argument function.

Inside the test you can call different assertions that are documented in detail later on.

Running Testy

You can run an individual test file using:

$ npx testy my_test.js

Or, you can run it without arguments to run all the tests (by default it looks on a tests folder located in the project root):

$ npx testy

You can also add it as the test script for npm/yarn in your package.json:

{
  ...
  "scripts": {
    "test": "npx testy"
  },
  ...
}

And then run the tests using npm test or yarn test.

Configuring Testy

Testy will look for a .testyrc.json configuration file in the project root directory. You can use this configuration as a template (values here are the defaults):

{
  "directory": "./tests",   // directory including your test files
  "filter": ".*_test.js$",  // which convention to use to recognize test files
  "language": "en",         // language of the output messages. "es" and "en" supported for now
  "failFast": false,        // enable/disable fail fast mode (stop as soon as a failed test appears)
  "randomOrder": false      // enable/disable execution of tests in random order
  "timeoutMs": 1000         // sets the per-test timeout in milliseconds
}

These are all the configuration parameters you can set. Feel free to change it according to your needs. When declaring this configuration, every test suite under the tests directory (matching files ending with *test.js) will be executed.

Examples and available assertions

There must be at least one assertion on the test to be valid. These are all the supported assertion types:

  • Boolean assertions:
    • assert.that(boolean).isTrue() or assert.isTrue(boolean). It does a strict comparison against true (object === true)
    • assert.that(boolean).isFalse() or assert.isFalse(boolean). It does a strict comparison against false (object === false)
  • Equality assertions:
    • assert.that(actual).isEqualTo(expected) or assert.areEqual(actual, expected).
    • assert.that(actual).isNotEqualTo(expected) or assert.areNotEqual(actual, expected)
    • Equality assertions use a deep object comparison (based on Node's assert module) and fail if objects under comparison have circular references.
    • Equality criteria on non-primitive objects can be specified:
      • Passing an extra two-arg comparator function to isEqualTo(expected, criteria) or areEqual(actual, expected, criteria)
      • Passing a method name that actual object understands: isEqualTo(expected, 'myEqMessage') or areEqual(actual, expected, 'myEqMessage')
      • By default, if actual has an equals method it will be used.
      • If we compare undefined with undefined using isEqualTo(), it will make the test fail. For explicit check for undefined, use the isUndefined()/isNotUndefined() assertions documented above.
  • Identity assertions:
    • assert.that(actual).isIdenticalTo(expected) or assert.areIdentical(actual, expected)
    • assert.that(actual).isNotIdenticalTo(expected) or assert.areNotIdentical(actual, expected)
    • Identity assertions check if two references point to the same object using the === operator.
  • Check for undefined presence/absence:
    • assert.that(aValue).isUndefined() or assert.isUndefined(aValue)
    • assert.that(aValue).isNotUndefined() or assert.isNotUndefined(aValue)
  • Check for null presence/absence:
    • assert.that(aValue).isNull() or assert.isNull(aValue)
    • assert.that(aValue).isNotNull() or assert.isNotNull(aValue)
  • Exception testing:
    • assert.that(() => { ... }).raises(error) or with regex .raises(/part of message/)
    • assert.that(() => { ... }).doesNotRaise(error)
    • assert.that(() => { ... }).doesNotRaiseAnyErrors()
  • Numeric assertions:
    • Comparators:
      • assert.that(aNumber).isGreaterThan(anotherNumber)
      • assert.that(aNumber).isLessThan(anotherNumber)
      • assert.that(aNumber).isGreaterThanOrEqualTo(anotherNumber)
      • assert.that(aNumber).isLessThanOrEqualTo(anotherNumber)
    • Rounding:
      • assert.that(aNumber).isNearTo(anotherNumber). There's a second optional argument that indicates the number of digits to be used for precision. Default is 4.
  • String assertions:
    • assert.that(string).matches(regexOrString) or assert.isMatching(string, regexOrString)
  • Array inclusion:
    • assert.that(collection).includes(object)
    • assert.that(collection).doesNotInclude(object)
    • assert.that(collection).includesExactly(...objects)
  • Emptiness
    • assert.that(collection).isEmpty() or assert.isEmpty(collection)
    • assert.that(collection).isNotEmpty() or assert.isNotEmpty(collection)
    • the collection under test can be an Array, a String or a Set

Please take a look at the tests folder, you'll find examples of each possible test you can write. Testy is self-tested.

Running testy globally

If you don't have a NPM project you can install testy globally using npm install -g testy and then run testy <files>

Other features

  • Running code before/after every test: just like many testing frameworks have, there is a way to execute some code before or after each test in a suite using the before() and after() functions, respectively. You can use only one definition of before() and after() per suite, and they always receive a function as argument. Example:

    ```javascript
    import { suite, test, assert, before, after } from '@pmoo/testy';
    
    suite('using the before() and after() helpers', () => {
      let answer;
    
      before(() => {
        answer = 42;
      });
    
      test('checking the answer', () => {
        assert.that(answer).isEqualTo(42);
      });
    
      after(() => {
        answer = undefined;
      });
    });
    ```
    
  • Support for pending tests: if a test has no body, it will be reported as [WIP] and it won't be considered a failure.

  • Support for skipped tests: you can skip a test by adding .skip() after test declaration, it will be reported as [SKIP] and it won't be executed nor considered a failure.

    ```javascript
    import { suite, test, assert } from '@pmoo/testy';
    
    suite('I am a suite with a skipped test', () => {
    
      test('I am a skipped test', async () => {
        assert.that(1).isEqualTo(1);
      }).skip();
    
    });
    ```
    
  • Support for asynchronous tests: if the code you are testing has async logic, you can await inside the test definition and make assertions later. You can also use it on before() and after() declarations. Example:

    ```javascript
    import { suite, test, assert, before } from '@pmoo/testy';
    
    const promiseOne = async () => Promise.resolve(42);
    const promiseTwo = async () => Promise.resolve(21);
    
    suite('using async & await', () => {
      let answerOne;
    
      before(async () => {
        answerOne = await promiseOne();
      });
    
      test('comparing results from promises', async () => {
        const answerTwo = await promiseTwo();
        assert.that(answerOne).isEqualTo(42);
        assert.that(answerTwo).isEqualTo(21);
      });
    });
    ```
    
  • Fail-Fast mode: if enabled, it stops execution in the first test that fails (or has an error). Remaining tests will be marked as skipped.

  • Run tests and suites in random order: a good test suite does not depend on a particular order. Enabling this setting is a good way to ensure that.

  • Strict check for assertions: if a test does not evaluate any assertion while it is executed, the result is considered an error. Basically, a test with no assertion is considered a "bad" test.

  • Explicitly failing or marking a test as pending: there's a possibility of marking a test as failed or pending, for example:

    import { suite, test, fail, pending } from "@pmoo/testy";
    
    suite("marking tests as failed and pending", () => {
      test("marking as failed", () => fail.with("should not be here"));
    
      test("marking as pending", () =>
        pending.dueTo("did not have time to finish"));
    });

    The output includes the messages provided:

    [FAIL] marking as failed
      => should not be here
    [WIP] marking as pending
      => did not have time to finish
    

Why?

Why another testing tool? The main reason is that we want to keep simplicity, something it's hard to see in the main testing tools out there.

  • Zero dependencies: right now, this project does not depend on any npm package, making the tool easy to install, and fast: essential to have immediate feedback while doing TDD. This is also good for installing on places where the internet connection is not good and we don't want to download hundreds of libraries.
  • Understandable object-oriented code: we want to use this tool for teaching, so eventually we'll look at the code during lessons, and students should be able to see what is going on, and even contributing at it, with no dark magic involved. Also, we try to follow good OO practices.
  • Unique set of features: we are not following any specification nor trying to copy behavior from other approaches (like the "xUnit" or "xSpec" way).

"Design Principles Behind Smalltalk" is a source of inspiration for this work. We try to follow the same principles here.

Contributing

Please take a look at the Contributing section.

Contributors

Thanks goes to these wonderful people (emoji key):


Facundo Javier Gelatti

⚠️ 💻

Tomer Ben-Rachel

⚠️ 💻

Abraão Duarte

💻

adico

💻 ⚠️

Askar Imran

💻 ⚠️

Nigel Yong

💻

Chelsie Ng

💻

Pablo T

⚠️ 💻

Francisco Jaimes Freyre

💻 ⚠️ 📖

giovannipessiva

🌍

Abhishek Khatri

💻

Ignacio Robledo

💻 ⚠️

Marco Ellwanger

💻 ⚠️

María Belén Amat

💻 ⚠️ 🌍 📖

This project follows the all-contributors specification. Contributions of any kind welcome!

testy's People

Contributors

abraaoduarte avatar adico1 avatar allcontributors[bot] avatar ask-imran avatar beluamat29 avatar chelsieng avatar franciscojaimesfreyre avatar giovannipessiva avatar ignacio-r avatar javiergelatti avatar mellster2012 avatar ngarbezza avatar niyonx avatar renovate[bot] avatar tomerpacific avatar trochepablo 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

testy's Issues

[feature] configuration to run tests in random order

Is your feature request related to a problem? Please describe.
Trying to diagnose the inter-dependency problems in tests.

Describe the solution you'd like
A configuration to indicate whether we want our tests to be evaluated in random order or not. It has to be disabled by default, to avoid confusion.

[feature] change `runTesty` to be more object-oriented

Is your feature request related to a problem? Please describe.
runTesty is a function when it should be something like Testy.run()... to be more consistent with the object-oriented style the tool has in general.

Describe the solution you'd like

const { Testy } = require('./testy');

Testy.configuredWith({
  directory: require('path').resolve('./tests'),
  language: 'en' // you can try 'es' to see spanish output
}).run();

[feature] isNearTo() assertion

Is your feature request related to a problem? Please describe.
There's no easy way to check for numbers when they have a floating point representation issues like 0.1 + 0.2. assert.that(0.1 + 0.2).isEqualTo(0.3) fails (and that's correct, but we don't have another way to say it's close enough). More info here.

Describe the solution you'd like
A new assertion that we can express the value is near according to certain precision:

  • assert.that(0.1 + 0.2).isNearTo(0.3)
  • assert.that(0.111).isNearTo(0.1, 1) # extra optional argument to indicate precision

Default precision should be 4 digits

[feature] comparing undefined with undefined should fail

Is your feature request related to a problem? Please describe.
Trying to prevent false positives where we think there's a value but we have undefined in both sides of the comparison. Also, assert.that().isEqualTo() passes and this feature will prevent that.

Describe the solution you'd like
assert.that(undefined).isEqualTo(undefined) should fail with a message like Assertion failed: actual and expected are both undefined.

[feature] ability to report location of a failed assertion

Is your feature request related to a problem? Please describe.
If a test fails and it had many assertions, you will see the error but it might be difficult to know where it was generated. Especially if there are many boolean assertions that do not have much more detail.

Describe the solution you'd like
If a test fails, indicate next (or below) the failure message the file and line number that triggered the failed assertion.

[bug] suite with no body fails

Describe the bug

Declaring a suite with no body fails with an error on undefined object.

To Reproduce

const { suite, test, assert } = require('@pmoo/testy');

suite('the minishell').run();

Expected behavior
It's ok if it says "no tests" o "0 tests"

[feature] Change assertion syntax to be more "fluent interface" style

Is your feature request related to a problem? Please describe.
It's not good to import a bunch of functions of the testy module

Describe the solution you'd like
This is a breaking change, but assertion syntax could change to:

assert.that(2).isEqualTo(2)
assert.areEqual(2, 2)
assert.that(() => { ... }).raises("an error")

That way, we just need to import just the assert object. Also, it feels more "object-oriented" style. And easy to add new assertions and even chain assertions and make assertions more strong/specific, like:

assert.that(() => { ... }).raises("an error").andAssert((error) => { ...post conditions... })

[refactoring] make i18n keys parameterized

Problem
Right now, if we have parameters inside a phrase, there's no way for interpolating those arguments

Proposed solution
A key can be a lambda or a string, and if it is a lambda, it can take the arguments and build the string as a result of the lambda.

[bug] if directory is not provided, configuration message should be more friendly

Describe the bug
If we run testy without the directory parameter, the script fails because if tries to read that property. And the error is not good for the end user.

To Reproduce
Steps to reproduce the behavior:

  1. Configure testy with no options (runTesty())
  2. Run the file
  3. See the error message is not clear.

Expected behavior
A message saying the directory parameter is required to run, and exit with status code 1 if that happens.

[feature] error if test does not have assertions

Is your feature request related to a problem? Please describe.
It is very helpful for students to enforce we are using the testing tool properly, that includes having at least one assertion in each written test.

Describe the solution you'd like
Set the result as ERROR because the test in those cases do not have any sense. Display why it's an error

[feature] pattern to match files to run

Is your feature request related to a problem? Please describe.
The problem is that we can specify to run every file of a folder, but probably we don't want to do that if we have another files that are not tests.

Describe the solution you'd like
Add another configuration parameter that is something like *_test.js to specify which files should match

[feature] equality message to use on isEqualTo and isNotEqualTo

Is your feature request related to a problem? Please describe.
Some objects define their own equality criteria, like Math.JS do with equals http://mathjs.org/docs/datatypes/units.html.

We already have a way to pass a function to customize the equality criteria to use, but it would be shorter to pass a function name, and even shorter, have equals as a default if nothing is passed (and objects have equals defined).

Describe the solution you'd like
When using isEqualTo or isNotEqualTo, allow to pass a String with a function name, and that parameter by default could be equals. Use this in the assertion implementation

[feature] allow to pass a regex to the raises() matcher

Is your feature request related to a problem? Please describe.
It's annoying that we have to test by the exact error object. We can test against the error message using a regex.

Describe the solution you'd like
assert.that(() => { myDangerous.code() }).raises(/error including this/). The assertion will pass if we receive an error or string object and the error message or the string has at least one match.

[feature] validate repeated suite and tests names

Is your feature request related to a problem? Please describe.
If suites or tests are repeated this is indicating a problem. We want to detect that before running the tests.

Describe the solution you'd like
Do not run the suite if it has duplicate test names, and does not run at all if it has duplicate test suites. Report an error message and exit with code 1

[feature] isNotEqualTo assertion

Is your feature request related to a problem? Please describe.
Trying to test if an object is not equal to another

Describe the solution you'd like
an assertion called isNotEqualTo, and eventually a shortcut call assertNotEqual

[bug] includesExactly() does not work with Set

Describe the bug
The includesExactly() matcher is failing even though a set includes the correct elements, and that is because the underlying implementation is assuming the collection is an array and it iterates it using positions.

To Reproduce
Steps to reproduce the behavior:

  1. Write a test with the assertion assert.that(new Set(1, 2, 3)).includesExactly(1, 2, 3)
  2. Run the test and watch it fail

Expected behavior
The assertion should pass because the set has exactly the described elements

[feature] runTesty with a relative path

Is your feature request related to a problem? Please describe.
In the current version, we need to pass directory: require('path').resolve('./tests') to convert the relative path to an absolute one.

Describe the solution you'd like
Allow runTesty to receive a relative path directory: './tests' which is more short and concise.

[feature] ability to report location of a test (file + line number)

Is your feature request related to a problem? Please describe.
Right now we're displaying the test suites and examples' names but without any reference on where they are located. So it's hard to navigate to a specific test.

Describe the solution you'd like
It would be nice to output, for any test, the file location + line number, so we can navigate to that test.

[feature] doesNotInclude(x) matcher

Is your feature request related to a problem? Please describe.
We're not able to use includes in a negative way.

Describe the solution you'd like
A matcher that we can call like: assert.that(myCollection).doesNotInclude(thing)

[feature] Run suite "inline"

Is your feature request related to a problem? Please describe.
Instead of having a runTesty() function that loads every file of a directory, there should be a way of executing a single file.

Describe the solution you'd like
A run() message to the suite to indicate it has to be executed inline. Otherwise, it'll be just declarated and waiting for another test runner to run it.

[feature] test failures summary

Is your feature request related to a problem? Please describe.
It's hard to see the failures if you have several tests/suites. You have to scroll in the console output to see the failures.

Describe the solution you'd like
At the end of the output, iff there are failures/errors, show them in a separate section including the message and description.

[feature] isNull() and isNotNull() assertions

Is your feature request related to a problem? Please describe.
Sometimes we want to assert that a value is or is not null and we would like a shortcut for that.

Describe the solution you'd like

  • assert.that(value).isNull()
  • assert.that(value).isNotNull()
  • assert.isNull(value)
  • assert.isNotNull(value)

[feature] ability to run a single file without `run()`

Is your feature request related to a problem? Please describe.
If we have many tests and we might want to focus just on one suite, we don't have a way to do that unless we add the run() at the end of a suite definition. This is not convenient and actually run() can be deprecated if we make this change.

Describe the solution you'd like
Pass a file name as an argument to a new command or use node tests.js and create a testy runner just for that file. If it has more than one suite, run all inside that file

[bug] runTesty directory does not take into account subdirectories

Describe the bug
Running testy with the directory option only looks in that directory, not in subdirectories.

To Reproduce
Steps to reproduce the behavior:

  1. create a folder under the test directory
  2. add some tests to it
  3. run testy
  4. those files are not being loaded/executed

Expected behavior
Recursively load every test file inside the directory specified.

[feature] ability to run a single test through the command line

Is your feature request related to a problem? Please describe.
If we have many tests and we might want to focus just on one, we don't have a way to do that.

Describe the solution you'd like
Pass a file name and a line number file_name:line_number as argument to a new command or use node tests.js and create a testy runner just for that test

[bug] prevent definition of multiple before() blocks

Describe the bug
If you define multiple before() blocks only the last one gets executed.

To Reproduce
Steps to reproduce the behavior:

  1. Create a test definition with two before sections
  2. Run the test
  3. See that only the last one ran

Expected behavior
Allow only one section. If there are multiple, fail and do not continue with test execution

[bug] test with more than one assertion does not fail at first failure

Describe the bug
If a test has more than one assertion, even if anyone fails, the test result is

To Reproduce
Steps to reproduce the behavior:

Create a test like this:

test('it should fail in the first error', () => {
  assert.isTrue(false);
  assert.isTrue(true);
});

And it passes.

Expected behavior
The test above should fail because at least one assertion have failed.

[feature] remove dependency on require-dir

Is your feature request related to a problem? Please describe.
As we are trying to get simplicity, it would be AWESOME if we have ZERO dependencies. We're using require-dir but in a very trivial way, just to recursively visit all files in a directory and require those files. That can be easily replaced with a simple recursive function.

Describe the solution you'd like
Rewrite the logic to load all the suites using a custom function that goes recursively on all files and directories from the starting point.

[feature] Mark test with body as pending

Is your feature request related to a problem? Please describe.
Having an unfinished test that is considered neither passed nor failed because it is pending

Describe the solution you'd like
A statement called pending(message) indicating in message what is left to implement. It can have a default text 'pending'. The test will be WIPed.

[feature] multilanguage support

Is your feature request related to a problem? Please describe.
As this is a learning tool, it would be nice to be multilanguage, so that students could see the messages in their native language.

Describe the solution you'd like
A configuration, probably in runTesty options, to indicate a language with a two-letter code, and every text outputed to the console being translated to that language. A future feature could be reading the locale from the system.

[feature] deprecate before() "context" style

Is your feature request related to a problem? Please describe.
Making the use of before() simpler.

Describe the solution you'd like
Deprecate the before() style that returns a context object. Instead, just set variables on the suite or any outer scope and use them as local variables. It is also easier for the IDE.

[feature] matcher: includesExactly

Is your feature request related to a problem? Please describe.
I want to check if a collection has all the elements I expect, in no particular order (so I cannot use areEqual/isEqualTo)

Describe the solution you'd like
assert.that(collection).includesExactly(obj1, obj2, ...) being the argument a vararg.

[feature] indicate file being executed in console output

Is your feature request related to a problem? Please describe.
It's good to see the suite name on the console output, but it will also be good to display the file path

Describe the solution you'd like
Output can be something like:

================================================================
file: <./relative/path>
suite: <suite name>
summary: 8 tests, 7 passed, 1 pending
================================================================

probably file, suite and summary with some enphasis or at least tab aligned.

[feature] "fail fast" mode

Is your feature request related to a problem? Please describe.
Some frameworks have this option called "fail fast" which stops the execution as soon as the first test fails.

Describe the solution you'd like
If one test fails on all the suites, stop the execution and display the results so far:

xxx tests passed, yyy tests skipped (those that were not)

[feature] isUndefined() and isNotUndefined() assertions

Is your feature request related to a problem? Please describe.
Sometimes we want to assert that a value is or is not undefined and we would like a shortcut for that.

Describe the solution you'd like

  • assert.that(value).isUndefined()
  • assert.that(value).isNotUndefined()
  • assert.isUndefined(value)
  • assert.isNotUndefined(value)

[feature] "testy" CLI script

Is your feature request related to a problem? Please describe.
Is not so professional to run testy using node, it's hard to customize and pass additional options.

Describe the solution you'd like
It would be nice to execute the tests not using node <testy file> but using testy <testy file>

[bug] running suites with run() fail because of unitialized fail fast mode

Describe the bug
When running the suite by calling run(), that is, not calling it from Testy configuration, it fails because the fail fast mode seems to be unitialized.

To Reproduce
Steps to reproduce the behavior:

  1. Create a test suite with a run() method
  2. Run it
  3. See the error

Expected behavior
Run with fail fast default (disabled).

[bug] pretty print of object with a circular dependency fails

Describe the bug
pretty print of object with a circular dependency fails

To Reproduce
do an assertion including an object that has a circular dependency

Expected behavior
We can display what the node console display in those cases:

> let a = { };
undefined
> let b = { a: a };
undefined
> a.b = b
{ a: { b: [Circular] } }

[bug] returning 0 error code when tests fail

Describe the bug
When the tests fail, the script returns 0 as error code, which means success and it does not trigger any failure if we put this on a CI server.

To Reproduce
Steps to reproduce the behavior:

  1. Define a suite with at least one error/failed test
  2. Run the tests
  3. Exit status code is zero

Expected behavior
Status code should be 1 (non zero).

[feature] colored output

Is your feature request related to a problem? Please describe.
It's not a problem, but a feature that could be very useful.

Describe the solution you'd like
Some color indicators for each test:

  • green for passing tests
  • yellow for pending tests
  • orange/red for failed tests
  • red for errored tests

[feature] isIncludedIn() and isNotIncludedIn() assertions

Is your feature request related to a problem? Please describe.
Sometimes we want to assert that a value is or is not included in a collection. Similar to includes() and doesNotInclude() but the other way around. Should work with Array and Sets.

Describe the solution you'd like

  • assert.that(value).isIncludedIn(collection)
  • assert.that(value).isNotIncludedIn(collection)

[feature] increase "debuggability"

Is your feature request related to a problem? Please describe.
Sometimes it's hard to debug and see what happens when are you registering a suite/test, running one or evaluating an assertion

Describe the solution you'd like

  • Avoid one-liners
  • Avoid tricky inlined expressions
  • Use descriptive names
  • Use local variables when necessary

[bug] suite() with no arguments generates an invalid suite

Describe the bug
Defining a suite without arguments (name and body) does not fail, and it generates the following output:

================================================================================

undefined:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Summary of undefined:
0 test(s)
================================================================================

To Reproduce
Steps to reproduce the behavior:

  1. Create a test suite file including a call to suite() with no arguments
  2. Run testy
  3. See the output displayed above

Expected behavior
Making both arguments (suite name and body) required and fail with a descriptive error message, and validates the name is a string and the body is a function.

[bug] poor error message when custom equality method is not found

Describe the bug
When we use assert.areEqual(o1, o2, 'custom') if custom is not a property we fail with a message like:

[ERROR] two points are equal if the x and y are both equal
  => TypeError: actual[criteria] is not a function

To Reproduce
Steps to reproduce the behavior:

  1. Write a test with an equality comparison using a custom property that is not on the objects
  2. Run the test
  3. See that the error message is a bit misleading

Expected behavior
The error message could be something like: Equality check failed. Objects do not have 'xxx' property

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.