Commit fa1ee60f authored by Evan Read's avatar Evan Read

Merge branch 'winh-frontend-testing-code-blocks-docs' into 'master'

Fix code blocks in frontend testing guide (docs)

See merge request gitlab-org/gitlab-ce!32002
parents d35788d7 f69dba8f
...@@ -232,7 +232,7 @@ module. GitLab has a custom `spyOnDependency` method which utilizes ...@@ -232,7 +232,7 @@ module. GitLab has a custom `spyOnDependency` method which utilizes
[babel-plugin-rewire](https://github.com/speedskater/babel-plugin-rewire) to [babel-plugin-rewire](https://github.com/speedskater/babel-plugin-rewire) to
achieve this. It can be used like so: achieve this. It can be used like so:
```js ```javascript
// my_module.js // my_module.js
import { visitUrl } from '~/lib/utils/url_utility'; import { visitUrl } from '~/lib/utils/url_utility';
...@@ -241,7 +241,7 @@ export default function doSomething() { ...@@ -241,7 +241,7 @@ export default function doSomething() {
} }
``` ```
```js ```javascript
// my_module_spec.js // my_module_spec.js
import doSomething from '~/my_module'; import doSomething from '~/my_module';
...@@ -847,7 +847,7 @@ See also the [RSpec testing guidelines](../testing_guide/best_practices.md#rspec ...@@ -847,7 +847,7 @@ See also the [RSpec testing guidelines](../testing_guide/best_practices.md#rspec
A `:js` flag is added to the test to make sure the full environment is loaded. A `:js` flag is added to the test to make sure the full environment is loaded.
```js ```ruby
scenario 'successfully', :js do scenario 'successfully', :js do
sign_in(create(:admin)) sign_in(create(:admin))
end end
...@@ -857,7 +857,7 @@ The steps of each test are written using capybara methods ([documentation](https ...@@ -857,7 +857,7 @@ The steps of each test are written using capybara methods ([documentation](https
Bear in mind <abbr title="XMLHttpRequest">XHR</abbr> calls might require you to use `wait_for_requests` in between steps, like so: Bear in mind <abbr title="XMLHttpRequest">XHR</abbr> calls might require you to use `wait_for_requests` in between steps, like so:
```rspec ```ruby
find('.form-control').native.send_keys(:enter) find('.form-control').native.send_keys(:enter)
wait_for_requests wait_for_requests
...@@ -871,7 +871,7 @@ expect(page).not_to have_selector('.card') ...@@ -871,7 +871,7 @@ expect(page).not_to have_selector('.card')
We have a helper available to make testing actions easier, as per [official documentation](https://vuex.vuejs.org/guide/testing.html): We have a helper available to make testing actions easier, as per [official documentation](https://vuex.vuejs.org/guide/testing.html):
```js ```javascript
testAction( testAction(
actions.actionName, // action actions.actionName, // action
{ }, // params to be passed to action { }, // params to be passed to action
...@@ -899,7 +899,7 @@ To make mounting a Vue component easier and more readable, we have a few helpers ...@@ -899,7 +899,7 @@ To make mounting a Vue component easier and more readable, we have a few helpers
Examples of usage: Examples of usage:
```js ```javascript
beforeEach(() => { beforeEach(() => {
vm = createComponentWithStore(Component, store); vm = createComponentWithStore(Component, store);
...@@ -909,7 +909,7 @@ beforeEach(() => { ...@@ -909,7 +909,7 @@ beforeEach(() => {
}); });
``` ```
```js ```javascript
beforeEach(() => { beforeEach(() => {
vm = mountComponentWithStore(Component, { vm = mountComponentWithStore(Component, {
el: '#dummy-element', el: '#dummy-element',
...@@ -921,7 +921,7 @@ beforeEach(() => { ...@@ -921,7 +921,7 @@ beforeEach(() => {
Don't forget to clean up: Don't forget to clean up:
```js ```javascript
afterEach(() => { afterEach(() => {
vm.$destroy(); vm.$destroy();
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment