0
0
Postmantesting~10 mins

Data file integration (CSV, JSON) in Postman - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to load a CSV data file in Postman.

Postman
pm.test('Load CSV data file', function () {
    const data = pm.iterationData.[1]();
    pm.expect(data).to.not.be.undefined;
});
Drag options to blanks, or click blank then click option'
AtoString
BtoCSV
CtoObject
DtoJSON
Attempts:
3 left
💡 Hint
Common Mistakes
Using toCSV() which does not exist.
Trying to convert to string instead of JSON object.
2fill in blank
medium

Complete the code to access the 'username' field from the current data row in Postman.

Postman
const username = pm.iterationData.get('[1]');
Drag options to blanks, or click blank then click option'
Auser
Busername
Cuser_name
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect field names like 'user' or 'name'.
Misspelling the field name.
3fill in blank
hard

Fix the error in the code to correctly iterate over data rows in Postman tests.

Postman
pm.test('Check data rows', function () {
    for (let i = 0; i < pm.iterationData.[1]; i++) {
        const email = pm.iterationData.get('email');
        pm.expect(email).to.include('@');
    }
});
Drag options to blanks, or click blank then click option'
Alength
Bsize
Ccount
Dlength()
Attempts:
3 left
💡 Hint
Common Mistakes
Using length() as a method instead of length property.
Using size or count which do not exist.
4fill in blank
hard

Fill both blanks to create a test that checks if the 'status' field equals 'active' for each data row.

Postman
pm.test('Status is active', function () {
    const status = pm.iterationData.get('[1]');
    pm.expect(status).to.be.[2]('active');
});
Drag options to blanks, or click blank then click option'
Astatus
Bequal
Cequals
DstatusCode
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'equals' instead of 'equal' which is not a Chai method.
Using wrong field names like 'statusCode'.
5fill in blank
hard

Fill all three blanks to create a test that verifies the 'age' field is greater than 18 for each data row.

Postman
pm.test('Age check', function () {
    const age = parseInt(pm.iterationData.get('[1]'), 10);
    pm.expect(age).to.be.[2]([3]);
});
Drag options to blanks, or click blank then click option'
Aage
Babove
C18
DgreaterThan
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'greaterThan' which is not a Chai method.
Comparing with a string instead of a number.