Day 06 - AssertionError: check base URL

Hi,

I need help with an error that I got when I submitted collection request.
I tried to find the solution but it seems that I got blind :slight_smile:
What have I done wrong?

here is the error message: Variables added correctly | AssertionError: check base URL: expected ‘’ to equal ‘http://security.postman-breakable.com

workspace ID: 4039722d-f55c-4109-a05b-e64a9bad5ea6

Hey @jitkanadenikova :wave:

A huge part of these challenges is being able to debug issues when they come up - Things are going to fail from time to time and knowing what’s failed and how to fix it is all part of the learning journey.

In your image, you show the results of the Tests - Those are not the actual tests. You can find those in the Tests section of the submit collection request.

The failing test relates to this:

pm.test("Variables added correctly", () => {

    let baseVar = collection.variable.find(variable => { return variable.key === 'baseUrl'})
    pm.expect(baseVar.key, 'check base URL variable set').to.equal('baseUrl')
    pm.expect(baseVar.value, 'check base URL').to.equal('http://security.postman-breakable.com')

    let tokenVar = collection.variable.find(variable => { return variable.key === 'token'})
    pm.expect(tokenVar.key, 'check token variable set').to.equal('token')

    let idVar = collection.variable.find(variable => { return variable.key === 'user_id'})
    pm.expect(idVar.key, 'check id variable set').to.equal('user_id')
    
    pass += 1
})

More specifically this part:

let baseVar = collection.variable.find(variable => { return variable.key === 'baseUrl'})
pm.expect(baseVar.key, 'check base URL variable set').to.equal('baseUrl')
pm.expect(baseVar.value, 'check base URL').to.equal('http://security.postman-breakable.com')

All of these submit collection requests are running the tests against the response body. If you take a look at the response body of the request and locate collection.variable array you will see a set of key/value pairs.

If the baseUrl doesn’t have a value set, this likely means that it’s not been added as an a initial value in the Collection level variable section.

If this is only in the current value, it’s not synced and therefore will not be returning in the response from the Postman API.

Opening up the Variables section at the Collection level, you can see that it’s not there so it’s probably only set as a current value in your instance and only you can see it.

Another great resource to help here is this create by @jetison which walks through how to review test results - Well worth checking out.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.