question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adonis tests are failing when we setup application on different PC or location or after re-installing the dependencies.

See original GitHub issue

Description

I don’t know if this is a bug or not but all tests are failing when I set up the adonis application on a different location or PC or in case I delete the node_modules directory and re-install the npm dependencies. At the moment, I found two issues :

  1. route from the test context is getting undefined.
  2. loginAs function is not working.

Test 1


  test('Need email|mobile & password to login.', async ({ client, route }) => {
    const response = await client.post(route('api.login')).accept('json')

    response.assertStatus(422)

    response.assert?.containsSubset(response.body(), {
      errors: [{ field: 'email' }, { field: 'password' }],
    })
  })

Test 2

test('An authenticated user can see the list of categories too.', async ({ client, assert }) => {
    const categories = await CategoryFactory.createMany(5)

    const user = await UserFactory.create()

    const response = await client.get('/api/categories').loginAs(user).accept('json')

    response.assertStatus(200)

    response.assert?.equal(5, response.body()?.length)

    assert.containsSubset(response.body(), categories.map(({ id, type, name }) => ({ id, type, name })))
  })

These tests were passing when I set up the fresh AdonisJS application but failed after re-installing dependencies/relocating by repo clone. I have attached two screenshots of the test results.

Expected Behaviour

If route and loginAs functions were passing before push (Push to git repo) then it should be working when I clone the code and installl the dependencies in another location or PC.

Steps to Reproduce

  1. Install the fresh adonis application via commands.
  2. Write some functional tests (just like above I mentioned). Tests should utilize the functions route from the test context and loginAs in test suite body. Tests should be passing.
  3. Delete node_modules directory OR move application files to the new location without node_modules directory and install dependencies via yarn
  4. Run the test command node ace test and the above two test examples will fail.

Package version

v2.0.7

Error Message & Stack Trace

image

image

Relevant Information

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
iyashpalcommented, May 3, 2022

@thetutlage thank you so much for the help. You made my day. Closing the issue now.

1reaction
iyashpalcommented, May 3, 2022

@thetutlage you must have received the invitation of the repo.

Read more comments on GitHub >

github_iconTop Results From Across the Web

init adonis-ts-app fails on Windows10 #2312 - GitHub
The only difference is, that I'm using Node Version 14.15.4 and NPM Version 6.14.10. If I run npm init adonis-ts-app adsd-mal --verbose I...
Read more >
Nodejs install adonis-framework get error - Stack Overflow
From the adonis documentation: Node.js version 4.0 or greater. npm version 3.0 or greater. You have to upgrade your npm version to 3.8.9...
Read more >
Automating the deploy of an Adonis.js API to Heroku | CircleCI
Testing the endpoints in Postman​​ Make sure that your app is running. If it is not, run adonis serve --dev to start it...
Read more >
Installation - AdonisJS
Getting started by creating and running a new AdonisJS application. ... Version Manager to install and run multiple versions of Node.js on your...
Read more >
Exploring the AdonisJS tests runner - YouTube
To be precise. We will go through the- Basic setup and flow of the AdonisJS tests runner- Authenticating users- Dealing with file uploads ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found