question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: test.fullTitle is not a function

See original GitHub issue

hi there,

mochasome looks really cool. i just tried to run it for the first time but straight run in an error 😦

Environment Information

npm: 3.10.7 node: v6.5.0 mocha: 3.0.2 mochasome: 1.5.2

Problem with mochawesome: TypeError: test.fullTitle is not a function
    at cleanTest (fullstack/npm/modules/array-numbers/node_modules/mochawesome/lib/mochawesome.js:256:21)
    at arrayMap (fullstack/npm/modules/array-numbers/node_modules/mochawesome/node_modules/lodash/index.js:1406:25)
    at Function.map (fullstack/npm/modules/array-numbers/node_modules/mochawesome/node_modules/lodash/index.js:6710:14)
    at cleanSuite (fullstack/npm/modules/array-numbers/node_modules/mochawesome/lib/mochawesome.js:166:22)
    at traverseSuites (fullstack/npm/modules/array-numbers/node_modules/mochawesome/lib/mochawesome.js:143:7)
    at Runner.<anonymous> (fullstack/npm/modules/array-numbers/node_modules/mochawesome/lib/mochawesome.js:78:9)
    at emitNone (events.js:91:20)
    at Runner.emit (events.js:185:7)
    at /Users/fullstackx/.nvm/versions/node/v6.5.0/lib/node_modules/mocha/lib/runner.js:798:12
    at /Users/fullstackx/.nvm/versions/node/v6.5.0/lib/node_modules/mocha/lib/runner.js:646:9
    at next (/Users/fullstackx/.nvm/versions/node/v6.5.0/lib/node_modules/mocha/lib/runner.js:285:14)
    at Immediate.<anonymous> (/Users/fullstackx/.nvm/versions/node/v6.5.0/lib/node_modules/mocha/lib/runner.js:327:5)
    at runCallback (timers.js:574:20)
    at tryOnImmediate (timers.js:554:5)
    at processImmediate [as _immediateCallback] (timers.js:533:5)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
CodingMadeEasycommented, Jan 28, 2017

I’m having the exact same issue but it has nothing to do with the describe. It happens when mocha.run() is called more than once.

Here’s my code:


import * as path from 'path';
import * as fs from 'fs';
import * as Mocha from 'mocha';
import * as React from 'react';
import * as chokidar from 'chokidar';

let mocha: Mocha = new Mocha(
{
    reporter: 'mochawesome',
    reporterOptions:
    {
        reportDir: __dirname + '/../../public/mochawesome'
    }
});

let testsPath: string = __dirname + '/../../tests/';
let fileList: Array<string> = fs.readdirSync(testsPath).filter(file => file.split('.').pop() == 'js');
fileList.forEach (file =>
{
    console.log(file);
    mocha.addFile(path.join(testsPath, file));
});

function Invalidate()
{
    fileList.forEach (p =>
    {
        let fullPath = path.join(testsPath, p);
        p = path.resolve(fullPath);
        delete require.cache[require.resolve(p)];
    });
}

export default class Tests extends React.Component<{}, {}>
{
    componentWillMount()
    {
        //mocha.run();

        let watcher = chokidar.watch(testsPath, {persistent: true});
        watcher.on('change', path =>
        {
            console.log('change');
            Invalidate();
            mocha.run();
            //this.forceUpdate();
        });

        watcher.on('add', p =>
        {
            if (p.split('.').pop() == 'js')
            {
                console.log('add');
                Invalidate();
                mocha.addFile(p);
                mocha.run();
                //this.forceUpdate();
            }
        });
    }

    render()
    {

        return (
            <html>
                <body>
                    <iframe src='/mocha/mochawesome.html' width='100%' height='100%'/>
                </body>
            </html>
        );
    }
}

And my test code:

"use strict";
const chai_1 = require("chai");
describe('testing', function () {
    it('will equal 1', () => {
        chai_1.expect(1).to.equal(2);
    });
});

When the add or watch event is called more than once, it fails.

0reactions
tgirishkumarcommented, Feb 15, 2017

I have the same issue as @CodingMadeEasy suggested

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mocha: Get current test's name of test generate on loop?
How I can improve my code for used this.test.fullTitle() directly on loop and avoid I used the variable testTitle and beforeEach function? node ......
Read more >
suite.js - Documentation - Mocha
function Suite(title, parentContext, isRoot) {; if (!isString(title)) ... test);; return this;; };; /**; * Return the full title generated by recursively ...
Read more >
mocha/mocha.js - chromium/src/third_party - Git at Google
throw new TypeError('"listener" argument must be a function');. events = target. ... Invalid ranges are not set to a default, so can range...
Read more >
mochajs/mocha - Gitter
I wonder if anyone can suggest a recipe for a set of tests against a piece of express.js middleware, ... I get a...
Read more >
api documentation for mocha (v3.3.0)
fullTitle (), test.duration); }); runner.on('fail', function (test) { cursor. ... createWriteStream) { throw new Error('file output not supported in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found