Giter VIP home page Giter VIP logo

Comments (7)

SeedyROM avatar SeedyROM commented on May 21, 2024 2

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.

RomainLanz avatar RomainLanz commented on May 21, 2024 1

Hey @SeedyROM! 👋

Simply define an env.testing file like the documentation said http://adonisjs.com/docs/4.1/testing#_env_testing.

from vow.

RomainLanz avatar RomainLanz commented on May 21, 2024 1

Yeah, those lines are commented by default in your vowfile.js

from vow.

SeedyROM avatar SeedyROM commented on May 21, 2024 1

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.

SeedyROM avatar SeedyROM commented on May 21, 2024

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.

SeedyROM avatar SeedyROM commented on May 21, 2024

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.

SeedyROM avatar SeedyROM commented on May 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.