-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to run LB3 app tests when the app is mounted in a LB4 project #3978
Comments
@nabdelgadir, could you please take a look? Thanks! |
Hi @kevintc, can you try: const {ApiApplication} = require('../../')
const app = new ApiApplication() |
@kevintc thank you for starting this discussion. First of all, why would you like to access LB4 application from your LB3 tests? In my mind, this creates a cyclic dependency (LB4 app depends on LB3 app, but your LB3 tests want to depend on LB4 app). Having said that, I think we didn't consider how to run LB3 app tests when the app is mounted in a LB4 project, so I am not surprised there are rough edges now. |
Hey, thanks for your answers @bajtos @nabdelgadir ! We managed to make tests work by booting both LB4 app (@nabdelgadir method 👍) and LB3 app (via require With LB4 Application we can retrieve open API spec and execute our end-to-end tests. However, we were wondering if there is a way to access our LB3 methods directly from LB4 application, without requiring LB3 server manually ? |
Sorry for the super delayed response! Do you have an example of a LB3 method that you'd want to access directly? |
@bajtos, could you please add acceptance criteria? thanks! |
Hmm, I think we need to clarify what user stories we want to document. Here is what I am thinking about: As a user migrating from LB3 to LB4, I created a new LB4 project and mounted my LB3 application as explained in https://github.com/strongloop/loopback-next/tree/master/examples/lb3-application Now I want to run my existing LB3 tests as part of LB4 project's There are two kinds of tests we need to support. Ideally, there should be a way how to run these tests from the original JavaScript files stored in the LB3 project, so that users don't have to migrate all test files to LB4.
As a bonus, let's take a look at accessing LB3 models from LB4 app (e.g. from LB4 controllers). In LB3, models are access via Acceptance criteria for the spike: investigate the following four tasks and propose a solution for each one. Create follow-up stories to document them and make any necessary runtime improvements.
|
Turning this issue as an epic. |
All the tasks in this epic are done. Closing this as done! |
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 haveconst app = require('../server/server')
.When trying to run the tests using
mocha ./lb3app/tests/main.js
app
is undefined.I tried
typescript-require
and:Expected Behavior
I expected a way to call the new lb4
app
object fromlb3
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
darwin x64 10.16.0
Related Issues
See Reporting Issues for more tips on writing good issues
The text was updated successfully, but these errors were encountered: