Jest cannot load script tag content, so jsonp cannot be tested

problem description

use the Jest framework to test a jsonp code, but the JsDom used by Jest seems to be unable to load the contents of the script tag, resulting in the global function of jsonp cannot be called. Therefore, the jsonp can not be done unilaterally.

The code for

jsonp is as follows:

import { jsonp } from "../src/jsonP";
test("jsonp", done => {
  jsonp("https://fake-collect.com", {a: "b"}, (err, data) => {
    expect(data).toBeTruthy();
    done();
  })
})

but each time a Error: ReqDynamic params Timeout error is thrown in the jsonp code, which represents a request timeout. Indicates that script cannot be caused by proper loading.

expected results

can run the whole process of jsonp correctly in the Jest framework, load the script` tag and the procedure that the global function is called

Jun.09,2021

Oh, my God, I found you again. Is there a solution to this problem?


jest.timeout set a longer number

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c2f41d-33c50.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c2f41d-33c50.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?