Comments (7)
I'm a complete idiot, I skimmed over that document so hard! Thanks for the clarification! Also thanks for the late (PST) reply. I will try that and close this issue. Hope other half-awake noobies find this question.
👌🏻🔥
from vow.
Hey @SeedyROM! 👋
Simply define an env.testing
file like the documentation said http://adonisjs.com/docs/4.1/testing#_env_testing.
from vow.
Yeah, those lines are commented by default in your vowfile.js
from vow.
I generated this app from a nuxt-create-app, which is clearly the main problem here! I will add an issue/question on Nuxt's repo to clarify this. I've obviously done way more modifications to the default template than testing, but this one bit me harder than any other.
Thanks so much for the clarifications!
from vow.
Here is my attempt with Factory mocks, now I get a connection error from what I can only perceive to be the client handler.
'use strict'
const { test, trait } = use('Test/Suite')('City')
const City = use('App/Models/City')
const Factory = use('Factory')
trait('DatabaseTransactions')
trait('Test/ApiClient')
test('get list of cities', async ({ client }) => {
const city = await Factory.model('App/Models/City').create()
const response = await client.get('/api/v1/cities').end()
response.assertStatus(200)
response.assertJSONSubset([{
code: city.code,
name: cide.name
}])
})
Here is what the test runner's output:
City
✖ get list of cities (23ms)
ERRORS
1. get list of cities
Error: connect ECONNREFUSED 127.0.0.1:3000
at Object._errnoException (util.js:999:13)
at _exceptionWithHostPort (util.js:1020:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1207:14)
FAILED
total : 1
failed : 1
time : 126ms
Realizing now, this may have something to do with the fact that I'm using Nuxt.js and starting from an igniter and not the standard CLI command. Not sure how this could mess stuff up exactly?
However I don't think that would effect the standard test runner considering everything else has been fine all night.
Sorry if this is n00b question, I'm very interested in this framework and will be willing to submit a pull request if I can find the issue myself.
from vow.
Thank you for marking this as a question and not an issue, that was my mistake.
So I've done what you've said (I also made a new DB for testing only, maybe this isn't correct?), but how do I run migrations for the test DB?
I'm getting an error saying the tables simply don't exist, which makes sense since the migrations haven't been run. I'm obviously missing something important. The docs shed no light on this from what I can see while perusing around.
City
✖ get list of cities (21ms)
ERRORS
1. get list of cities
error: relation "cities" does not exist
at Connection.parseE (/home/rombus/Workspace/codetemp/js/tdr2/node_modules/pg/lib/connection.js:545:11)
at Connection.parseMessage (/home/rombus/Workspace/codetemp/js/tdr2/node_modules/pg/lib/connection.js:370:19)
at Socket.<anonymous> (/home/rombus/Workspace/codetemp/js/tdr2/node_modules/pg/lib/connection.js:113:22)
at Socket.emit (events.js:159:13)
at addChunk (_stream_readable.js:265:12)
at readableAddChunk (_stream_readable.js:252:11)
at Socket.Readable.push (_stream_readable.js:209:10)
at TCP.onread (net.js:608:20)
From previous event:
at Client_PG._query (/home/rombus/Workspace/codetemp/js/tdr2/node_modules/knex/lib/dialects/postgres/index.js:287:12)
at Client_PG.query (/home/rombus/Workspace/codetemp/js/tdr2/node_modules/knex/lib/client.js:199:17)
at /home/rombus/Workspace/codetemp/js/tdr2/node_modules/knex/lib/transaction.js:274:21
From previous event:
at Client_PG.trxClient.query (/home/rombus/Workspace/codetemp/js/tdr2/node_modules/knex/lib/transaction.js:271:34)
at Runner.<anonymous> (/home/rombus/Workspace/codetemp/js/tdr2/node_modules/knex/lib/runner.js:149:36)
From previous event:
at /home/rombus/Workspace/codetemp/js/tdr2/node_modules/knex/lib/runner.js:61:21
at runCallback (timers.js:773:18)
at tryOnImmediate (timers.js:734:5)
at processImmediate [as _immediateCallback] (timers.js:711:5)
From previous event:
at Runner.run (/home/rombus/Workspace/codetemp/js/tdr2/node_modules/knex/lib/runner.js:47:31)
at Builder.Target.then (/home/rombus/Workspace/codetemp/js/tdr2/node_modules/knex/lib/interface.js:35:43)
at Proxy.<anonymous> (/home/rombus/Workspace/codetemp/js/tdr2/node_modules/@adonisjs/lucid/lib/proxyGet.js:58:21)
FAILED
total : 1
failed : 1
time : 126ms
Thanks again for the timely responses.
from vow.
https://github.com/adonisjs/adonis-blog-demo/blob/master/vowfile.js#L36
This is the correct setup for my testing purposes, I missed this link as well.
Please close this issue and have a good night!
from vow.
Related Issues (20)
- grep option is a misnomer HOT 1
- Is the destructured `test` imported the same as `japa`? HOT 1
- Test file upload HOT 1
- Error: Cannot find module 'Session/Client' HOT 4
- Asynchronous trait HOT 1
- Using DatabaseTransactions does not play well with app transactions HOT 10
- Test/ApiClient send is not processing data the same way server does HOT 2
- When writing tests, how can I get data in session ? HOT 2
- list of directories to run tests from in config file HOT 2
- Testing Websockets
- Adding custom reporter HOT 5
- Response Assert Json Structure HOT 3
- adonis make:test fails and hangs HOT 4
- When writing test how can i make the adonis test command test only a specific file instead of all files in the folder HOT 1
- Test methods not chainable
- Tests does not call authorize inside validators
- Fix order of test files
- Ability to set hook timeouts HOT 2
- list of directories to run tests from in config file HOT 1
- Adonis session not persisting between tests HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vow.