Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test failure with large string is extremely slow #1168

Closed
shunjikonishi opened this issue Jun 19, 2018 · 1 comment
Closed

Test failure with large string is extremely slow #1168

shunjikonishi opened this issue Jun 19, 2018 · 1 comment

Comments

@shunjikonishi
Copy link

I'm using mocha and chai.

When I run test with large string and it fails, mocha stops long time.

Initially I made an issue on mocha.

mochajs/mocha#3416

But mocha guys says it is an issue for chai.

I'm not sure why it takes long time.
Please take a look.

Steps to Reproduce

Run this test.

"use strict";

const expect = require("chai").expect;

// Make large string
// If loop count is 10000, the test never finish.
const largeString = (function() {
    let result = "";
    for (let i=0; i<3000; i++) {
        result += "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
    }
    return result;
})();

describe("Very slow test", () => {

    it("compare large string", () => {
        expect("a").to.equal(largeString);
    });
});

Versions

mocha = 5.2.0
node = v8.8.1
chai = v4.1.2

@keithamus
Copy link
Member

Hey @shunjikonishi thanks for the issue.

We're aware of this issue. It's due to our inspection engine which has trouble trying to turn big values into strings. This will be fixed in Chai 5 which will include a rewrite of the inspection engine to deal with such large values, and the inspection engine will only be called when a test fails. We'll be releasing chai 5 soon, but for now I'll close this issue because it is tracked on our roadmap (https://github.com/chaijs/chai/projects/2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants