0

When I try to run my frisbyjs tests with jest as documented on the github page, I get the following error:

RangeError: Maximum call stack size exceeded
    at String.slice (native)
    at Object.resolve (path.js:290:29)
    at resolveConfigPathByTraversing (C:\Users\me\AppData\Roaming\npm\node_modules\jest\node_modules\jest-config\build\resolve_config_path.js:58:54)
    at resolveConfigPathByTraversing (C:\Users\me\AppData\Roaming\npm\node_modules\jest\node_modules\jest-config\build\resolve_config_path.js:75:10)
    at resolveConfigPathByTraversing (C:\Users\me\AppData\Roaming\npm\node_modules\jest\node_modules\jest-config\build\resolve_config_path.js:75:10)
    at resolveConfigPathByTraversing (C:\Users\me\AppData\Roaming\npm\node_modules\jest\node_modules\jest-config\build\resolve_config_path.js:75:10)
    at resolveConfigPathByTraversing (C:\Users\me\AppData\Roaming\npm\node_modules\jest\node_modules\jest-config\build\resolve_config_path.js:75:10)
    at resolveConfigPathByTraversing (C:\Users\me\AppData\Roaming\npm\node_modules\jest\node_modules\jest-config\build\resolve_config_path.js:75:10)
    at resolveConfigPathByTraversing (C:\Users\me\AppData\Roaming\npm\node_modules\jest\node_modules\jest-config\build\resolve_config_path.js:75:10)
    at resolveConfigPathByTraversing (C:\Users\me\AppData\Roaming\npm\node_modules\jest\node_modules\jest-config\build\resolve_config_path.js:75:10)

I believe I have the correct file structure, using "__tests__" and my test file "api.spec.js" in that folder, but I might have something wrong going on. Disclaimer: I'm brand new to Javascript and all related knowledge. I previously worked on Java.

I'm working on a proof of concept using Frisby with Jasmine to write live API tests. My current project structure is as follows:

  • __tests__
    • helpers
      • environment.js
    • api.spec.js

The file contents are as follows:

environment.js

module.exports = {
    oneApiUrl: "https://mywebsite.net/",
    twoApiUrl: "https://myotherwebsite.com/projectpoint/",
    dashboardProjectsApi: 'api/dashboard/projects/get',
    token: 'tokenstringhere',
};

api.spec.js

const frisby = require('frisby');
const environment = require('./helpers/environment.js');


frisby.globalSetup({
    request: {
        headers: {
            'Authorization': 'Bearer ' + environment.token,
        }
    }
});

describe('Dashboard api', function () {
    it('should return list of projects this user can access', function (done) {
        frisby.get(environment.oneApiUrl + environment.dashboardProjectsApi)
            .expect('status', 200)
            .done(done);
    });
});

I'm pretty sure it's not the test, as this works if I do jasmine-node .\api.spec.js. I can go with using jasmine-node, but there's benefits to using jest and I would like to know why this isn't working.

I tried Googling the error, but this error typically comes from issues related to a javascript website, doubling up on imports in the html, etc. I don't think mine is related to that, as I'm trying to run the js file like one would run python, with an interpreter. (As far as I understand.)

Any suggestions/critiques are appreciated!

1 Answer 1

0

Turns out I HAD to have a package.json file in the project to get jest to run. Verified by adding a package.json file at the _tests_ level of the project. Removing the package.json reproduced the error. Even though there doesn't seem to be any obvious affect of this file on jest, it won't run tests without it. This sadly is a result of my lack of knowledge on the requirements for javascript tests and related tools. I stumbled on the solution because I knew I wanted my project to be runnable elsewhere and thus needed a package.json to allow for easy deployment with the 'npm install' command.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.