Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ff4773d4
Commit
ff4773d4
authored
Sep 27, 2021
by
Albert Salim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update doc on importing fixture
parent
b9d5c280
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
doc/development/testing_guide/frontend_testing.md
doc/development/testing_guide/frontend_testing.md
+10
-5
No files found.
doc/development/testing_guide/frontend_testing.md
View file @
ff4773d4
...
...
@@ -783,20 +783,25 @@ often using fixtures to validate correct integration with the backend code.
### Use fixtures
Jest uses
`spec/frontend/__helpers__/fixtures.js`
to import fixtures in tests.
The following are examples of tests that work for Jest:
To import a JSON fixture,
`import`
it using the
`test_fixtures`
alias.
```
javascript
import
responseBody
from
'
test_fixtures/some/fixture.json
'
// loads spec/frontend/fixtures/some/fixture.json
it
(
'
makes a request
'
,
()
=>
{
const
responseBody
=
getJSONFixture
(
'
some/fixture.json
'
);
// loads spec/frontend/fixtures/some/fixture.json
axiosMock
.
onGet
(
endpoint
).
reply
(
200
,
responseBody
);
myButton
.
click
();
// ...
});
```
For other fixtures, Jest uses
`spec/frontend/__helpers__/fixtures.js`
to import them in tests.
The following are examples of tests that work for Jest:
```
javascript
it
(
'
uses some HTML element
'
,
()
=>
{
loadFixtures
(
'
some/page.html
'
);
// loads spec/frontend/fixtures/some/page.html and adds it to the DOM
...
...
@@ -860,7 +865,7 @@ end
This will create a new fixture located at
`tmp/tests/frontend/fixtures-ee/graphql/releases/graphql/queries/all_releases.query.graphql.json`
.
You can import the JSON fixture in a Jest test using the
`
getJSONFixture`
method
You can import the JSON fixture in a Jest test using the
`
test_fixtures`
alias
[
as described below
](
#use-fixtures
)
.
## Data-driven tests
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment