Adonis tests are failing when we setup application on different PC or location or after re-installing the dependencies.
See original GitHub issueDescription
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 :
route
from the test context is getting undefined.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
- Install the fresh adonis application via commands.
- Write some functional tests (just like above I mentioned). Tests should utilize the functions
route
from the test context andloginAs
in test suite body. Tests should be passing. - Delete
node_modules
directory OR move application files to the new location withoutnode_modules
directory and install dependencies viayarn
- Run the test command
node ace test
and the above two test examples will fail.
Package version
v2.0.7
Error Message & Stack Trace
Relevant Information
Issue Analytics
- State:
- Created a year ago
- Comments:10 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@thetutlage thank you so much for the help. You made my day. Closing the issue now.
@thetutlage you must have received the invitation of the repo.