Skip to content

Timeout when attempting to run test annotated with @Theory #1

@msche

Description

@msche

When I try to run the following test,

@Suite("Test Utils")
class UtilsTests extends UnitTest {

    @Theory("Extract property value from correct formated URLs: ", [
        ["www.uniknow.org/UtilsTest?name=value", "name", "value"],
        ["www.uniknow.org/?name=value", "name", "value"]
    ])
    getParameterValueFromProperlyFormattedUrl(url:string, parameterName:string, result: string) {
        var extractedValue = Utils.getParamFromUrl(url,parameterName)
        assert.equal(extractedValue ,result);
    }
}

I get the following message in my console:

2 failing

1) Test Utils 0: Extract property value from correct formated URLs: www.uniknow.org/UtilsTest?name=value,name,value:
  Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.


2) Test Utils 1: Extract property value from correct formated URLs: www.uniknow.org/?name=value,name,value:
  Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.

If I split the test in separate @Fact tests the tests are working.

The class under test is as follows:

"use strict";

/**
 * Common utility class containing helper functions
 */
class Utils {


    /**
     * General helper method for extracting parameter value from specified url.
     *
     * @example
     * Utils.getParamFromUrl("http://eam.org/eamt?param=vale", "param") // => "value"
     *
     * @param url URL from which parameter name will be extracted
     * @param name Name of parameter we want to extract from the URL
     *
     * @return Value of specified parameter or null
     */
    static getParamFromUrl(url:string, name:string) {
        name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");

        var regexS = "[\\?&]" + name + "=([^&#]*)";
        var regex = new RegExp(regexS);

        var results = regex.exec(url);

        if (results == null) {
            return null;
        } else {
            return results[1];
        }
    }
}

export = Utils;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions