Skip to content

Commit

Permalink
Develop (#1992)
Browse files Browse the repository at this point in the history
Develop

Co-authored-by: null <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Anton Synenko <[email protected]>
  • Loading branch information
3 people authored Aug 13, 2019
2 parents fe3c3ca + 8967548 commit 926eed4
Show file tree
Hide file tree
Showing 19 changed files with 212 additions and 64 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ In addition to built-in Hexo tags, we have written several custom ones. They hel

### Adding Examples

To add a blog, talk or podcast to our docs, submit a [pull request](#Pull-Requests) with your data added to the corresponding [blogs.yml](/source/_data/blogs.yml), [talks.yml](/source/_data/talks.yml), or [podcasts.yml](/source/_data/podcasts.yml) file.
To add a course, blog, talk, podcast, or screencast to our docs, submit a [pull request](#Pull-Requests) with your data added to the corresponding [courses.yml](/source/_data/courses.yml), [blogs.yml](/source/_data/blogs.yml), [talks.yml](/source/_data/talks.yml), [podcasts.yml](/source/_data/podcasts.yml) or [screencasts.yml](/source/_data/screencasts.yml) file.

Add an associated image with the example within the [`source/img/examples`](/source/img/examples) directory. Each image should have a resolution of **715×480**. Reference the image in the markdown document as follows:

Expand Down
19 changes: 17 additions & 2 deletions cypress/integration/contentful_banners_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,23 @@ const allBannersYaml = 'source/_data/banners.yml'

describe('Contentful driven banners', () => {
it('displays all current banners with proper info', function () {
cy.readFile(allBannersYaml)
.then((yamlString) => YAML.parse(yamlString))
cy.task('readFileMaybe', allBannersYaml)
.then((yamlString) => {
if (typeof yamlString === 'undefined' || yamlString === null) return this.skip()

const yamlObject = YAML.parse(yamlString)

// remove all outdated or future banners
const setMyTimezoneToDate = (date) => new Date(Date.parse(date))

return yamlObject.filter((banner) => {
const now = new Date()
const startDate = setMyTimezoneToDate(banner.startDate)
const endDate = setMyTimezoneToDate(banner.endDate)

return startDate <= now && now <= endDate
})
})
.then((banners) => {
if (typeof banners === 'undefined' || !banners || !banners.length) return this.skip()

Expand Down
11 changes: 11 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
const fs = require('fs')

const baseUrlEnvMap = {
'https://docs-staging.cypress.io': 'staging',
Expand All @@ -27,5 +28,15 @@ module.exports = (on, config) => {
// or base url or set as development by default
config.env.NODE_ENV = getNodeEnv(config.baseUrl)

on('task', {
readFileMaybe (filename) {
if (fs.existsSync(filename)) {
return fs.readFileSync(filename, 'utf8')
}

return null
},
})

return config
}
55 changes: 32 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"gulp": "4.0.2",
"gulp-clean": "0.4.0",
"gulp-rev-all": "2.0.2",
"husky": "3.0.2",
"husky": "3.0.3",
"inquirer": "6.5.0",
"jest": "24.8.0",
"keyv": "3.1.0",
Expand All @@ -119,7 +119,7 @@
"request-promise": "4.2.4",
"sinon": "7.4.1",
"sinon-chai": "3.3.0",
"start-server-and-test": "1.9.2",
"start-server-and-test": "1.10.0",
"stop-only": "3.1.0",
"textlint": "11.3.1",
"textlint-filter-rule-comments": "1.2.2",
Expand Down
16 changes: 16 additions & 0 deletions source/_data/blogs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ small:

# large links with thumbnails, links, embedded video
large:
- title: "Going Automotive: Increasing Quality"
url: https://blog.noredink.com/post/186956536122/going-automotive-increasing-quality-to-misquote
sourceName: "NoRedInk"
sourceUrl: https://blog.noredink.com/
author: Matt Charlton
date: Aug 12, 2019
img: /img/examples/no-red-ink-automating-with-cypress-tests-adnvantages.jpg

- title: "The concept of Monitoring Tests"
url: https://dev.to/noriste/the-concept-of-monitoring-tests-4l5j
sourceName: "DEV.to"
Expand Down Expand Up @@ -368,6 +376,14 @@ large:
date: Apr 29, 2019
img: /img/examples/test-vue-apps-with-cypress.png

- title: "Testing with Cypress"
url: https://medium.com/@genedarocha/testing-with-cypress-8b62debe4ac6
sourceName: "Medium"
sourceUrl: https://medium.com/@genedarocha
author: Gene Da Rocha
date: Apr 27, 2019
img: /img/examples/testing-in-cypress-palm-trees.jpg

- title: "Pragmatic Front-End Testing Strategies (3)"
url: https://medium.com/@toastui/pragmatic-front-end-testing-strategies-3-969469349043
sourceName: Medium
Expand Down
4 changes: 4 additions & 0 deletions source/api/commands/readfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ You can assert that a file does not exist like so:
cy.readFile('does-not-exist.yaml').should('not.exist')
```

### Read a file that might not exist

{% url "See our example on using `cy.task()` to read a file that *may* not exist." task#Read-a-file-that-might-not-exist %}

## Retries

### Automatic retries
Expand Down
67 changes: 38 additions & 29 deletions source/api/commands/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ cy.task(event, arg, options)
// in test
cy.task('log', 'This will be output to the terminal')
```

```javascript
// in plugins file
on('task', {
log (message) {
console.log(message)
module.exports = (on, config) => {
on('task', {
log (message) {
console.log(message)

return null
}
})
return null
}
})
}
```

## Arguments
Expand All @@ -54,14 +57,16 @@ cy.task('hello', { greeting: 'Hello', name: 'World' })

```javascript
// in plugins/index.js
on('task', {
// deconstruct the individual properties
hello ({ greeting, name }) {
console.log('%s, %s', greeting, name)
module.exports = (on, config) => {
on('task', {
// deconstruct the individual properties
hello ({ greeting, name }) {
console.log('%s, %s', greeting, name)

return null
}
})
return null
}
})
}
```

**{% fa fa-angle-right %} options** ***(Object)***
Expand Down Expand Up @@ -105,15 +110,17 @@ cy.task('readFileMaybe', 'my-file.txt').then((textOrNull) => { ... })
// in plugins/index.js
const fs = require('fs')

on('task', {
readFileMaybe (filename) {
if (fs.existsSync(filename)) {
return fs.readFileSync(filename, 'utf8')
}
module.exports = (on, config) => {
on('task', {
readFileMaybe (filename) {
if (fs.existsSync(filename)) {
return fs.readFileSync(filename, 'utf8')
}

return null
}
})
return null
}
})
}
```

### Seed a database
Expand Down Expand Up @@ -157,14 +164,16 @@ cy.task('pause', 1000)

```javascript
// in plugins/index.js
on('task', {
pause (ms) {
return new Promise((resolve) => {
// tasks should not resolve with undefined
setTimeout(() => resolve(null), ms)
})
}
})
module.exports = (on, config) => {
on('task', {
pause (ms) {
return new Promise((resolve) => {
// tasks should not resolve with undefined
setTimeout(() => resolve(null), ms)
})
}
})
}
```

## Options
Expand Down
4 changes: 4 additions & 0 deletions source/guides/getting-started/installing-cypress.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ yarn add cypress --dev

If you're not using Node or `npm` in your project or you just want to try Cypress out quickly, you can always {% url "download Cypress directly from our CDN" https://download.cypress.io/desktop %}.

{% note warning %}
Recording runs to the Dashboard is not possible from the direct download. This download is only intended as a quick way to try out Cypress. To record tests to the Dashboard, you'll need to install Cypress as an `npm` dependency.
{% endnote %}

The direct download will always grab the latest available version. Your platform will be detected automatically.

Just manually unzip and double click. Cypress will run without needing to install any dependencies.
Expand Down
4 changes: 4 additions & 0 deletions source/zh-cn/guides/getting-started/installing-cypress.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ yarn add cypress --dev

如果你没有在项目中使用Node或`npm`,又或者你只是想快速使用Cypress, 你可以{% url "直接从我们的CDN下载" http://download.cypress.io/desktop %}。

{% note warning %}
Recording runs to the Dashboard is not possible from the direct download. This download is only intended as a quick way to try out Cypress. To record tests to the Dashboard, you'll need to install Cypress as an `npm` dependency.
{% endnote %}

它将自动识别你的平台,并直接下载最新的可用版本。

只需手动解压然后双击app。 Cypress就可以在不安装任何依赖的情况下运行.
Expand Down
1 change: 1 addition & 0 deletions themes/cypress/layout/partial/after_footer.swig
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!-- Scripts -->
<!-- build:js /js/application.js -->
{{ js('js/mobile_detect') }}
{{ js('js/banners_actualization') }}
{{ js('js/global_variable') }}
{{ js('js/lang_select') }}
Expand Down
2 changes: 1 addition & 1 deletion themes/cypress/layout/partial/header.swig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% endif %}
>
{{ partial('banners') }}
<div {% if not className %} id="header-inner" class="inner" {% else %} class="inner header-inner" {% endif %}>
<div {% if not className %} id="header-inner" {% endif %} class="inner header-inner">
<h1 {% if not className %} id="logo-wrap" {% else %} class="logo-wrap" {% endif %}>
<a href="https://www.cypress.io" {% if not className %} id="logo" {% else %} class="logo" {% endif %}>
<img src="/{{ config.logo }}" alt="Cypress"/>
Expand Down
6 changes: 5 additions & 1 deletion themes/cypress/source/css/_partial/banners.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
background-color: $color-green;
border-bottom: 1px solid $color-link;
font-family: $font-title;
padding: 20px 30px;
padding: 6px 20px;

@media screen and(min-width: 768px) {
padding: 20px 30px;
}

.top-banners_item--body {
display: inline-flex;
Expand Down
Loading

0 comments on commit 926eed4

Please sign in to comment.