Unable to run `sls test` without logging into Serverless

Hey there! I am creating a CI/CD pipeline using Gitlab. I have the pipeline consuming AWS secrets from Gitlab environment variables, which allows me to successfully deploy a staging stack. However, when the job in the pipeline reaches sls test --stage staging it fails out:

$ serverless test --stage staging
 
  Type Error ---------------------------------------------
 
  TypeError: Cannot read property 'classes' of undefined
      at module.exports.test (/usr/lib/node_modules/serverless/node_modules/@serverless/enterprise-plugin/lib/test/index.js:12:24)
      at ServerlessEnterprisePlugin.<anonymous> (/usr/lib/node_modules/serverless/node_modules/@serverless/enterprise-plugin/lib/plugin.js:511:17)
      at /usr/lib/node_modules/serverless/lib/classes/PluginManager.js:521:55
      at tryCatcher (/usr/lib/node_modules/serverless/node_modules/bluebird/js/release/util.js:16:23)
      at Object.gotValue (/usr/lib/node_modules/serverless/node_modules/bluebird/js/release/reduce.js:168:18)
      at Object.gotAccum (/usr/lib/node_modules/serverless/node_modules/bluebird/js/release/reduce.js:155:25)
      at Object.tryCatcher (/usr/lib/node_modules/serverless/node_modules/bluebird/js/release/util.js:16:23)
      at Promise._settlePromiseFromHandler (/usr/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:547:31)
      at Promise._settlePromise (/usr/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:604:18)
      at Promise._settlePromiseCtx (/usr/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:641:10)
      at _drainQueueStep (/usr/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:97:12)
      at _drainQueue (/usr/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:86:9)
      at Async._drainQueues (/usr/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:102:5)
      at Immediate.Async.drainQueues (/usr/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:15:14)
      at processImmediate (internal/timers.js:461:21)
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     Operating System:          linux
     Node Version:              12.20.0
     Framework Version:         2.13.0
     Plugin Version:            4.1.2
     SDK Version:               2.3.2
     Components Version:        3.4.2

The relevant lines in the stack trace are:

  if (!ctx.sls.enterpriseEnabled) {
    throw new this.sls.classes.Error('Run "serverless" to configure your service for testing.');
  }

I was able to configure the server using serverless to setup an account, and when developing locally, and this allowed me to run the tests in serverless.test.yml. However, this is not desired. I don’t particularly want this project attached to Serverless’ infrastructure.

Please let me know if there is any way that I can perform this task without logging into Serverless. I tried the following:

# .serverlessrc
{
    "enterpriseDisabled": true
}

However this provided me with the same stack trace that I referenced above. Any help that can be provided would be most appreciated!

Thanks!

1 Like

I am getting the same error when running sls test. I tried the suggestions here: Disable serverless enterprise wrapper to no avail. Did you ever find a solution?

Hi there,

I believe this functionality is now entirely locked behind their enterprise offering. I never did find a solution.