diff --git a/packages/bruno-lang/v2/src/bruToJson.js b/packages/bruno-lang/v2/src/bruToJson.js index 3cf65f1ba..25bae096d 100644 --- a/packages/bruno-lang/v2/src/bruToJson.js +++ b/packages/bruno-lang/v2/src/bruToJson.js @@ -80,8 +80,8 @@ const grammar = ohm.grammar(`Bru { bodymultipart = "body:multipart-form" dictionary script = scriptreq | scriptres - scriptreq = "script:req" st* "{" nl* textblock tagend - scriptres = "script:res" st* "{" nl* textblock tagend + scriptreq = "script:pre-request" st* "{" nl* textblock tagend + scriptres = "script:post-response" st* "{" nl* textblock tagend tests = "tests" st* "{" nl* textblock tagend docs = "docs" st* "{" nl* textblock tagend }`); diff --git a/packages/bruno-lang/v2/src/jsonToBru.js b/packages/bruno-lang/v2/src/jsonToBru.js index 9d56fa7e2..9b7ce146f 100644 --- a/packages/bruno-lang/v2/src/jsonToBru.js +++ b/packages/bruno-lang/v2/src/jsonToBru.js @@ -211,7 +211,7 @@ ${indentString(body.xml)} } if(script && script.req && script.req.length) { - bru += `script:req { + bru += `script:pre-request { ${indentString(script.req)} } @@ -219,7 +219,7 @@ ${indentString(script.req)} } if(script && script.res && script.res.length) { - bru += `script:res { + bru += `script:post-response { ${indentString(script.res)} } diff --git a/packages/bruno-lang/v2/tests/fixtures/request.bru b/packages/bruno-lang/v2/tests/fixtures/request.bru index 544a9dafe..f2e4fc0e1 100644 --- a/packages/bruno-lang/v2/tests/fixtures/request.bru +++ b/packages/bruno-lang/v2/tests/fixtures/request.bru @@ -84,7 +84,7 @@ assert { ~$res.body.message: success } -script:req { +script:pre-request { const foo = 'bar'; } diff --git a/packages/bruno-lang/v2/tests/script.spec.js b/packages/bruno-lang/v2/tests/script.spec.js index c68ddf2e4..3ef9da9a2 100644 --- a/packages/bruno-lang/v2/tests/script.spec.js +++ b/packages/bruno-lang/v2/tests/script.spec.js @@ -6,7 +6,7 @@ const parser = require("../src/bruToJson"); describe("script parser", () => { it("should parse request script", () => { const input = ` -script:req { +script:pre-request { $req.setHeader('Content-Type', 'application/json'); } `; @@ -22,7 +22,7 @@ script:req { it("should parse response script", () => { const input = ` -script:res { +script:post-response { expect(response.status).to.equal(200); } `;