I'm making automated acceptance tests for a JSON REST API, using NodeUnit. I've a test for creating resources, which returns the created resource (according to this specification) and I would like to compare the result from the API with my own JSON object, like:
test.deepEqual(response.body.data, {
type: 'Employees',
id: '1',
attributes: { Name: 'Marten', Birthdate: '1995/05/25' },
relationships: {
Speciality: {
links: {
self: testBase.baseUrl + 'Employees/1/relationships/Speciality',
related: testBase.baseUrl + 'Employees/1/Speciality'
}
}
},
links: { self: testBase.baseUrl + 'Employees/1' }
});
Just one problem: since the tests (NodeUnit) are asynchronously, the Id of the created resource could be anything. In this case '1', but it could be '2' or even '95'. So, is there a possibility for using a wildcard instead of a numeric value?