-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable insomnia.test and insomnia.expect in scripting - INS-3637 (
#7202) * feat: enable insomnia.test and insomnia.expect in scripting * fix: lint error * feat: enable replaceIn method
- Loading branch information
Showing
9 changed files
with
143 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { configure, type ConfigureOptions, type Environment as NunjuncksEnv } from 'nunjucks'; | ||
|
||
class Intepolator { | ||
private engine: NunjuncksEnv; | ||
|
||
constructor(config: ConfigureOptions) { | ||
this.engine = configure(config); | ||
} | ||
|
||
render = (template: string, context: object) => { | ||
// TODO: handle timeout | ||
// TODO: support plugin? | ||
return this.engine.renderString(template, context); | ||
}; | ||
} | ||
|
||
const intepolator = new Intepolator({ | ||
autoescape: false, | ||
// Don't escape HTML | ||
throwOnUndefined: true, | ||
// Strict mode | ||
tags: { | ||
blockStart: '{%', | ||
blockEnd: '%}', | ||
variableStart: '{{', | ||
variableEnd: '}}', | ||
commentStart: '{#', | ||
commentEnd: '#}', | ||
}, | ||
}); | ||
|
||
export function getIntepolator() { | ||
return intepolator; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export function test( | ||
msg: string, | ||
fn: () => void, | ||
log: (message?: any, ...optionalParams: any[]) => void, | ||
) { | ||
try { | ||
fn(); | ||
log(`✓ ${msg}`); | ||
} catch (e) { | ||
log(`✕ ${msg}: ${e}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters