Constructor
new FixturesLoader(fixturesDiropt)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
fixturesDir |
string
|
<optional> |
'fixtures' | The name of the fixtures directory relative to feature |
Methods
configure(fixturesDiropt)
Configures the loader
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
fixturesDir |
string
|
<optional> |
'fixtures' | The name of the fixtures directory relative to feature |
load(fixture) → {Promise.<(Object|string)>}
Tries to load a fixture from current feature directory.
Will search for the following file extensions:
- yaml
- yml
- js
- json
- txt
Parameters:
Name | Type | Description |
---|---|---|
fixture |
string
|
Fixture file name without extension |
Returns:
- Type:
-
Promise.<(Object|string)>
Fixture content
loadJson(file) → {Promise.<Object>}
Loads content from json file.
Parameters:
Name | Type | Description |
---|---|---|
file |
string
|
File path |
Returns:
- Type:
-
Promise.<Object>
Json data
loadModule(file) → {Promise.<*>}
Loads content from javascript module.
Parameters:
Name | Type | Description |
---|---|---|
file |
string
|
File path |
Returns:
- Type:
-
Promise.<*>
Data generated from the module
loadText(file) → {Promise.<string>}
Loads content from file.
Parameters:
Name | Type | Description |
---|---|---|
file |
string
|
File path |
Returns:
- Type:
-
Promise.<string>
File content
loadYaml(file) → {Promise.<(Object|Array)>}
Loads content from yaml file.
Parameters:
Name | Type | Description |
---|---|---|
file |
string
|
File path |
Returns:
- Type:
-
Promise.<(Object|Array)>
Parsed yaml data
setFeatureUri(featureUri)
Sets feature uri, used to resolve fixtures files.
When trying to load a fixture file the path will be comprised of:
- feature uri
- fixturesDir
- fixture name
Parameters:
Name | Type | Description |
---|---|---|
featureUri |
string
|
Feature uri |