-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: rename events to pactumEvents * feat: utils findFile clone and sleep * chore: expect to allow normal assertions
- Loading branch information
1 parent
a9fe231
commit 29e8337
Showing
15 changed files
with
130 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
const { EventEmitter } = require('events'); | ||
|
||
/** | ||
* @deprecated | ||
*/ | ||
const events = new EventEmitter(); | ||
|
||
const pactumEvents = new EventEmitter(); | ||
|
||
const EVENT_TYPES = { | ||
BEFORE_REQUEST: "BEFORE_REQUEST", | ||
AFTER_RESPONSE: "AFTER_RESPONSE", | ||
} | ||
|
||
module.exports = { | ||
events, | ||
pactumEvents, | ||
EVENT_TYPES | ||
} |
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,15 @@ | ||
export function clone<T>(input: T): T; | ||
|
||
/** | ||
* sleeps for a certain amount of time | ||
* @param {number} ms the amount of time to sleep in milliseconds | ||
* @returns | ||
*/ | ||
export function sleep(ms: number): Promise<void>; | ||
|
||
/** | ||
* find a file recursively in a directory | ||
* @param name the name of the file | ||
* @param dir the directory to search in. Defaults to config.data.dir | ||
*/ | ||
export function findFile(name: string, dir?: string): string; |
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,35 @@ | ||
const { findFileRecursively } = require("../helpers/file.utils"); | ||
const config = require("../config"); | ||
const { klona } = require("klona"); | ||
|
||
const utils = { | ||
|
||
clone(value) { | ||
return klona(value); | ||
}, | ||
|
||
/** | ||
* sleeps for a certain amount of time | ||
* @param {number} ms the amount of time to sleep in milliseconds | ||
* @returns | ||
*/ | ||
sleep(ms) { | ||
return new Promise(resolve => setTimeout(resolve, ms)); | ||
}, | ||
|
||
/** | ||
* finds a file recursively in a directory | ||
* @param {string} name | ||
* @param {string} dir | ||
* @returns | ||
*/ | ||
findFile(name, dir = config.data.dir) { | ||
const result = findFileRecursively(name, dir); | ||
if (result) { | ||
return result; | ||
} | ||
throw new Error(`File Not Found - '${name}'`); | ||
} | ||
} | ||
|
||
module.exports = utils; |
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
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
Oops, something went wrong.