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

TypeError: value.split is not a function #4029

Closed
2 tasks
wehrstedt opened this issue Sep 25, 2019 · 3 comments
Closed
2 tasks

TypeError: value.split is not a function #4029

wehrstedt opened this issue Sep 25, 2019 · 3 comments
Labels
area: reporters involving a specific reporter duplicate been there, done that, got the t-shirt... type: bug a defect, confirmed by a maintainer

Comments

@wehrstedt
Copy link

Prerequisites

  • [x ] Checked that your issue hasn't already been filed by cross-referencing issues with the faq label
  • Checked next-gen ES issues and syntax problems by using the same environment and/or transpiler configuration without Mocha to ensure it isn't just a feature that actually isn't supported in the environment in question or a bug in your code.
  • 'Smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, your usage of Mocha, or Mocha itself
  • [ x] Ensured that there is no discrepancy between the locally and globally installed versions of Mocha. You can find them with: node node_modules/.bin/mocha --version(Local) and mocha --version(Global). We recommend that you not install Mocha globally.

Description

The text execution fails with the following error message:

/home/ubuntu/jenkins/workspace/<path>/node_modules/mocha/node_modules/diff/lib/diff/line.js:19

      linesAndNewlines = value.split(/(\n|\r\n)/);

                               ^



TypeError: value.split is not a function

    at Diff.split [as tokenize] (/home/ubuntu/jenkins/workspace/<path>/node_modules/mocha/node_modules/diff/src/diff/line.js:7:32)

    at Diff.tokenize [as diff] (/home/ubuntu/jenkins/workspace/<path>/node_modules/mocha/node_modules/diff/src/diff/base.js:27:39)

    at diff (/home/ubuntu/jenkins/workspace/<path>/node_modules/mocha/node_modules/diff/src/diff/line.js:31:71)

    at structuredPatch (/home/ubuntu/jenkins/workspace/<path>/node_modules/mocha/node_modules/diff/src/patch/create.js:11:16)

    at structuredPatch (/home/ubuntu/jenkins/workspace/<path>/node_modules/mocha/node_modules/diff/src/patch/create.js:101:16)

    at Object.createTwoFilesPatch [as createPatch] (/home/ubuntu/jenkins/workspace/<path>/node_modules/mocha/node_modules/diff/src/patch/create.js:125:10)

    at unifiedDiff (/home/ubuntu/jenkins/workspace/<path>/node_modules/mocha/lib/reporters/base.js:424:18)

    at Function.exports.generateDiff (/home/ubuntu/jenkins/workspace/<path>/node_modules/mocha/lib/reporters/base.js:187:7)

    at XUnit.test (/home/ubuntu/jenkins/workspace/<path>/node_modules/mocha/lib/reporters/xunit.js:168:23)

    at /home/ubuntu/jenkins/workspace/<path>/node_modules/mocha/lib/reporters/xunit.js:106:12

    at Array.forEach (<anonymous>)

    at Runner.<anonymous> (/home/ubuntu/jenkins/workspace/<path>/node_modules/mocha/lib/reporters/xunit.js:105:11)

    at Object.onceWrapper (events.js:313:30)

    at emitNone (events.js:111:20)

    at Runner.emit (events.js:208:7)

    at Runner.uncaught (/home/ubuntu/jenkins/workspace/<path>/node_modules/mocha/lib/runner.js:868:8)

    at process.uncaught (/home/ubuntu/jenkins/workspace/<path>/node_modules/mocha/lib/runner.js:887:10)

    at emitOne (events.js:116:13)

    at process.emit (events.js:211:7)

    at process.emit (/home/ubuntu/jenkins/workspace/<path>/node_modules/source-map-support/source-map-support.js:465:21)

    at process._fatalException (bootstrap_node.js:391:26)

error Command failed with exit code 7.

Steps to Reproduce

Expected behavior: [No exception]

Actual behavior: [Test execution aborts]

Reproduces how often: [Every run]

Versions

  • The output of mocha --version and node node_modules/.bin/mocha --version:
node node_modules/.bin/mocha --version
E:\<Path>\node_modules\.bin\mocha:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^

SyntaxError: missing ) after argument list
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

(Version is 6.2.0)

  • The output of node --version: v10.16.3
  • Your shell (e.g., bash, zsh, PowerShell, cmd): Git bash

Additional Information

@JakeRowsell89
Copy link

I tried reproducing the version part of that (It looks like those strings aren't escaped) without success. That said, my file did not have that line either. I'm on MacOS if that helps.

Using Node 10.16.3, mocha 6.2.0 and NPM 6.9.0.

@ganshin-yaroslav
Copy link

This is repeated if you compare an object and a string

chai = require('chai')
describe('test', function() {
   it('test', function() {
      chai.expect('asdasd').to.equal({'asd': 'asd'});
   });
});

using node 12.13.1 mocha 6.2.0 and chai 4.2.0

@juergba
Copy link
Member

juergba commented Jan 27, 2020

  • exception when creating diff with XUnit reporter: fixed by XUnit reporter should handle exceptions during diff generation #4068
  • exception when node node_modules/.bin/mocha --version: this is an incorrect call by the user.
    the binaries within node_modules/.bin/ are called without prefixed node.
    ==> correct call: node_modules/.bin/mocha --version

@juergba juergba closed this as completed Jan 27, 2020
@juergba juergba added type: bug a defect, confirmed by a maintainer duplicate been there, done that, got the t-shirt... area: reporters involving a specific reporter and removed unconfirmed-bug labels Jan 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: reporters involving a specific reporter duplicate been there, done that, got the t-shirt... type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

No branches or pull requests

4 participants