serverless-jest-plugin icon indicating copy to clipboard operation
serverless-jest-plugin copied to clipboard

"TypeError: serverless.classes.Variables is not a constructor" when invoking a test

Open feg624 opened this issue 1 year ago • 9 comments

When using the following versions:

"serverless": "^3.19.0",
"serverless-jest-plugin": "^0.4.0",

and executing npx sls invoke test

the following error is reported:

Error:
TypeError: serverless.classes.Variables is not a constructor
    at /home/franco/repos/palm-serverless/node_modules/serverless-jest-plugin/lib/run-tests.js:13:18
    at Promise._execute (/home/franco/repos/palm-serverless/node_modules/bluebird/js/release/debuggability.js:384:9)
    at Promise._resolveFromExecutor (/home/franco/repos/palm-serverless/node_modules/bluebird/js/release/promise.js:518:18)
    at new Promise (/home/franco/repos/palm-serverless/node_modules/bluebird/js/release/promise.js:103:10)
    at runTests (/home/franco/repos/palm-serverless/node_modules/serverless-jest-plugin/lib/run-tests.js:8:3)
    at ServerlessJestPlugin.<anonymous> (/home/franco/repos/palm-serverless/node_modules/serverless-jest-plugin/index.js:97:23)
    at ServerlessJestPlugin.tryCatcher (/home/franco/repos/palm-serverless/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/franco/repos/palm-serverless/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/home/franco/repos/palm-serverless/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromiseCtx (/home/franco/repos/palm-serverless/node_modules/bluebird/js/release/promise.js:641:10)
    at _drainQueueStep (/home/franco/repos/palm-serverless/node_modules/bluebird/js/release/async.js:97:12)
    at _drainQueue (/home/franco/repos/palm-serverless/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/home/franco/repos/palm-serverless/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/home/franco/repos/palm-serverless/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (node:internal/timers:466:21)
    at process.topLevelDomainCallback (node:domain:152:15)
    at process.callbackTrampoline (node:internal/async_hooks:128:24)

It seems that on file run-tests.js, the lines 13 and 14 are not needed with the latest version of serverless.

feg624 avatar Jul 29 '22 22:07 feg624

+1 I have exactly the same problem.

nomurashunta avatar Aug 04 '22 02:08 nomurashunta

+1 same problem. Can I create a PR just deleting those lines?

bdelamotte avatar Sep 04 '22 01:09 bdelamotte

encountering the same problem +1

EmmanDizon avatar Sep 14 '22 02:09 EmmanDizon

@bdelamotte can you create pull request to fix this issue ?

EmmanDizon avatar Sep 14 '22 02:09 EmmanDizon

+1

FaridSafi avatar Dec 09 '22 06:12 FaridSafi

+1

ZentPeople avatar Dec 15 '22 08:12 ZentPeople

+1 Jest version: ~29.3.1 serverless-jest-plugin version: ~0.4.0

Error: TypeError: Class extends value #<Object> is not a constructor or null

leosantosw avatar Jan 10 '23 02:01 leosantosw

Same problem.

"jest": "^29.5.0"
"serverless-jest-plugin": "^0.4.0"
`TypeError: serverless.classes.Variables is not a constructor`

notmrhidden avatar Apr 09 '23 23:04 notmrhidden

It should be noted that the in the serverless library, the last reference to Serverless.classes.Variables is established in version 2.72.3.

This library does not appear to be updated for v3 of serverless, despite it's been out for more than a year now.

wjziv avatar Apr 18 '23 23:04 wjziv