Skip to content

How to run LB3 app tests when the app is mounted in a LB4 project #3978

@kevintc

Description

@kevintc

Steps to reproduce

Migration from lb3 to lb4, our legacy app lives in ./lb3app and tests (using Mocha) are in ./lb3app/tests

Current Behavior

In ./lb3app/tests/main.js, we have const app = require('../server/server').
When trying to run the tests using mocha ./lb3app/tests/main.js app is undefined.

I tried typescript-require and:

const { ApiApplication } = require('../../src/index.ts')
const app = new ApiApplication()

Expected Behavior

I expected a way to call the new lb4 app object from lb3 tests framework.
Or do we need to write all the tests again in .ts?

Link to reproduction sandbox

Our current setup is close to this one: https://github.com/strongloop/loopback-next/tree/master/examples/lb3-application
I'll see if I can add mocha to it.

Additional information

node -e 'console.log(process.platform, process.arch, process.versions.node)':

darwin x64 10.16.0

npm ls --prod --depth 0 | grep loopback:

├── @loopback/boot@1.5.8
├── @loopback/booter-lb3app@1.3.2
├── @loopback/context@1.23.2
├── @loopback/core@1.10.4
├── @loopback/openapi-v3@1.9.9
├── @loopback/repository@1.15.1
├── @loopback/rest@1.20.1
├── @loopback/rest-explorer@1.4.1
├── @loopback/service-proxy@1.3.8
├── loopback@3.26.0
├── loopback-boot@3.3.1
├── loopback-component-explorer@6.4.0
├── loopback-component-oauth2@3.2.0
├── loopback-component-passport@3.10.0
├── loopback-connector-es@1.4.1
├── loopback-connector-mongodb@3.9.2
├── loopback-connector-mysql@2.4.1
├── loopback-connector-rest@3.5.0
├── loopback-context@3.4.0

Related Issues

See Reporting Issues for more tips on writing good issues

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions