Most of us are increasingly turning to AI-powered tools, and for good reason... it's wildly efficient especially for redundant or tedious tasks. One great example is using Bruno, the Git-based API client, with Cursor, the AI-powered IDE.
What makes this combination possible is Bruno's unique approach to storing API collections and requests as plaintext files, making them easily readable and modifiable in any code editor.
At Bruno, we believe in making API testing as efficient as possible. By storing collections as plaintext files, Bruno enables seamless integration with modern development tools like Cursor / Copilot / Augment / Etc. This means you can leverage AI assistance directly on your API collections, right in your code editor.
Here's how to set it up and make the most of this powerful combination.
Out of the box, Cursor (and other coding assistants) works fine with Bruno, but you can bring it to the next level by providing a bit of guidance. This is optional but recommended.
Below is a configuration file that can be placed in the root of your workspace, either in a .cursor
directory, or just as a file like .bru-
test-config.json
.
I've set this configuration file specifically for testing, so it won't create new requests or folders for you but feel free to modify it as you'd like. We have users that are automatically updating collections based on code changes, or having documentation auto-generated for them. There's a ton of possibility here.
{
"bru_test_config": {
"file_rules": {
"base_path": ".",
"allowed_paths": ["*.bru"],
"forbidden_actions": [
"create_new_files",
"create_new_folders",
"modify_paths"
],
"edit_rules": {
"must_use_existing_path": true,
"must_use_relative_paths": true
}
},
"test_structure": {
"required_sections": [
"tests { ... }",
"docs { ... }"
],
"test_format": "test(\"test name\", () => { ... })",
"common_test_categories": [
"request_structure",
"response_status",
"response_body",
"data_validation"
]
},
"bru_methods": {
"request": {
"get_body": "req.getBody()",
"get_headers": "req.getHeaders()",
"get_params": "req.getParams()"
},
"response": {
"get_status": "res.getStatus()",
"get_body": "res.getBody()",
"get_headers": "res.getHeaders()"
}
},
"assertion_patterns": {
"property_exists": "expect(obj).to.have.property('prop')",
"type_check": "expect(value).to.be.a('type')",
"array_check": "expect(arr).to.be.an('array')",
"status_check": "expect(res.getStatus()).to.equal(200)",
"value_equals": "expect(value).to.equal(expected)",
"array_length": "expect(arr).to.have.lengthOf(n)",
"array_contains": "expect(arr).to.include(value)"
},
"common_test_patterns": {
"request_structure": `
test("Validate request structure", () => {
const body = req.getBody();
// Check top-level properties
expect(body).to.have.property('propName');
expect(body.propName).to.be.a('type');
// Check nested structures
const nested = body.propName;
expect(nested).to.have.property('nestedProp');
});
`,
"response_validation": `
test("Validate response", () => {
expect(res.getStatus()).to.equal(200);
const responseBody = res.getBody();
expect(responseBody).to.be.an('object');
});
`,
"array_validation": `
test("Validate array contents", () => {
const items = req.getBody().items;
expect(items).to.be.an('array');
items.forEach(item => {
expect(item).to.have.property('requiredProp');
});
});
`,
"data_type_validation": `
test("Validate data types", () => {
const data = req.getBody().data;
expect(data.id).to.be.a('number');
expect(data.name).to.be.a('string');
expect(data.items).to.be.an('array');
});
`
},
"best_practices": {
"test_organization": [
"Group related tests together",
"Use descriptive test names",
"Test one concept per test",
"Include both positive and negative cases"
],
"validation_priorities": [
"Request structure first",
"Response status second",
"Response body structure third",
"Data validation last"
],
"error_handling": [
"Test for required fields",
"Validate data types",
"Check array contents",
"Verify nested structures"
]
}
}
}
By combining Bruno's powerful API testing capabilities with Cursor's AI assistance, you can create a more efficient and productive development environment. The key is to set up your environment correctly and follow best practices for organizing your collections and tests. With the right setup, you can significantly reduce the time spent on test creation and maintenance, allowing you to focus on what matters most: building great APIs.