refactor: bring js-sandbox project to the monorepo

This commit is contained in:
Andrew Bastin
2021-09-25 00:59:09 +05:30
parent 9698932bde
commit d2865c637c
23 changed files with 1725 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
import { pipe } from "fp-ts/lib/function"
import { chain, right } from "fp-ts/lib/TaskEither"
import { execPreRequestScript } from "./preRequest"
import { execTestScript, TestResponse, TestDescriptor as _TestDescriptor } from "./test-runner"
export type TestDescriptor = _TestDescriptor
/**
* Executes a given test script on the test-runner sandbox
* @param testScript The string of the script to run
* @returns A TaskEither with an error message or a TestDescriptor with the final status
*/
export const runTestScript = (
testScript: string,
response: TestResponse
) => pipe(
execTestScript(testScript, response),
chain((results) => right(results[0])) // execTestScript returns an array of descriptors with a single element (extract that)
)
/**
* Executes a given pre-request script on the sandbox
* @param preRequestScript The script to run
* @param env The envirionment variables active
* @returns A TaskEither with an error message or an array of the final environments with the all the script values applied
*/
export const runPreRequestScript = execPreRequestScript