AssertionError's and JSONError in Newman build that don't happen locally

Hi there,

I’m trying to test my Rest API with a Newman collection during my travis build.
Unfortunately, the build fails and I don’t understand Travis behavior: the collection is executed with the environment (as expected), but I don’t managed to get the expected result code of my requests…

Locally when I start my containers then execute the collection with Postman, everything works fine. I also tried to start my containers then execute the collection with Newman (basically the same command that is executed by travis) and it also runs perfectly fine.

Here is my travis file (I even tried to get the same versions of node, npm and newman that I have locally on my laptop):

sudo: required
    dist: trusty
    language: node_js
      - "12.9.0"

      - npm install newman

      - docker

    organization: "REDACTED"
      secure: "REDACTED"


      - sudo rm /usr/local/bin/docker-compose
      - curl -L${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
      - chmod +x docker-compose
      - sudo mv docker-compose /usr/local/bin

      - docker-compose up -d --build
      - node --version
      - npm --version
      - node_modules/.bin/newman --version

      - node_modules/.bin/newman run tests/collection.json -e tests/environment.json
      - sonar-scanner

      - docker-compose down

And here is the result in the travis build:

    `  #  failure         detail                                                            
970 1.  AssertionError  Status code is 201                                                
971                     expected response to have status code 201 but got 200             
972                     at assertion:0 in test-script                                     
973                     inside "Scenario / Create User"                           
975 2.  JSONError                                                                         
976                     Unexpected token 'C' at 1:1                                       
977                     Connection error: SQLSTATE[HY000] [2002] Connection refused<br /> 
978                     ^                                                                 
979                     at test-script                                                    
980                     inside "Scenario / Login User"                            
982 3.  AssertionError  Status code is 200                                                
983                     expected response to have status code 200 but got 401             
984                     at assertion:0 in test-script                                     
985                     inside "Scenario / ReadCurrent User"                      

Locally the first request do return a 201 result code, why am I getting a 200 there (my code returns 201 or 4xx, never 200 for this request)??

The second request runs fine locally (200) and the third also returns a 200 result code. The 401 here is because I use a wrong JWT token due to the second (failed) request. But I have no idea why I got a Unexpected token 'C' at 1:1 in travis and not locally neither where the error come from ?

Thanks in advance

Please link to the build intead of copying stuff here selectively – that doesn’t give all the information needed for diagnostics.

In any case, at first glance, this looks like a problem with your code that you’ll need to debug. You can request debug mode for your project to make that easier.

It could possibly be due to differences between your machine and Travis VMs, but JSONError: Unexpected token 'C' at 1:1 looks like a code bug – perhaps you forgot to commit some changes.