Skip to content

Commit 27841ee

Browse files
authored
cypress-dotenv v3.x
- Upgrading Cypress and DotEnv to the latest version - Dropping support for anything below Node v18 - Minimum version of Cypress is now v10 - Fixing #32
2 parents 7d3cb9f + 8652bf4 commit 27841ee

File tree

14 files changed

+4019
-2460
lines changed

14 files changed

+4019
-2460
lines changed

.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ NON_CYPRESS_TEST_VAR=goodbye
33
CYPRESS_BASE_URL=http://google.com
44
CYPRESS_ENV=testing
55
CYPRESS_I_AM_NUMBER=100
6-
CYPRESS_I_AM_BOOLEAN=true
6+
CYPRESS_I_AM_BOOLEAN=true
7+
CYPRESS_I_AM_A_NUMBER_WITH_LEADING_ZERO=0100

.github/pull_request_template.md

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,9 @@ Please fill out this section with a description of your changes and your approac
1010

1111
_fill me out 📝_
1212

13-
## How to test/verify these changes
13+
## Verification Checklist
1414

15-
<!--
16-
Replace the sample steps below with steps on how a reviewer of this PR can test your changes. This should include things such as (if applicable):
17-
* Do you need to use a specific account to log in?
18-
* Is there a particular patient profile that should be used?
19-
-->
20-
21-
1. Clone this branch and run: `npm run cypress`
22-
1. Next, do thing 1
23-
1. Now do thing 2
24-
1. Notice that XYZ has changed
25-
26-
27-
## Screenshots and/or video
28-
29-
<!--
30-
If relevant, make sure to include relevant video or before/after screenshots that demonstrate the changes.
31-
If no visuals are required, then please fill out this section with "N/A"
32-
-->
33-
34-
_fill me out 📸_
15+
- [ ] Provided a good description of the changes introduced with this PR.
16+
- [ ] Written adequate unit tests (if necessary)
17+
- [ ] Updated the README (if necessary)
18+
- [ ] Make sure things still work with v10 and up of Cypress

.github/workflows/pr-quality-checks.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Run a number of quality checks ever time a PR is opened
22
name: Pull Request Quality Checks
33

4+
permissions:
5+
contents: read
6+
pull-requests: read
47
on:
58
workflow_dispatch:
69
inputs:
@@ -60,3 +63,20 @@ jobs:
6063
env:
6164
CI: true
6265
NODE_ENV: test
66+
67+
integration-testing:
68+
name: Integration testing
69+
runs-on: ubuntu-latest
70+
needs: setup
71+
steps:
72+
# restore dependencies that were installed in the `setup` job
73+
- name: Restore dependencies
74+
uses: actions/cache@v3
75+
with:
76+
path: |
77+
./*
78+
~/.npm
79+
key: ${{ github.sha }}
80+
81+
- name: Cypress Run
82+
uses: cypress-io/github-action@v6

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20
1+
18

README.md

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Cypress dotenv
22

3-
Cypress plugin that enables compatability with [dotenv](https://www.npmjs.com/package/dotenv).
3+
Cypress plugin that enables compatibility with [dotenv](https://www.npmjs.com/package/dotenv).
4+
5+
> [!NOTE]
6+
> If you need support for Cypress v9 or below, please use [v2.x of this plugin](https://github.com/morficus/cypress-dotenv/tree/v2.0.2)
7+
48

59
[![Build Status](https://travis-ci.org/morficus/cypress-dotenv.svg?branch=master)](https://travis-ci.org/morficus/cypress-dotenv)
610
[![Maintainability](https://api.codeclimate.com/v1/badges/0d189dae8e924ada81ad/maintainability)](https://codeclimate.com/github/morficus/cypress-dotenv/maintainability)
@@ -35,41 +39,33 @@ yarn add --dev dotenv cypress-dotenv
3539

3640
## Configure
3741

38-
Cypress (< 10.0.0)
39-
40-
Since this is a plugin, you will need to modify your file `cypress/plugins/index.js` to look something like this:
41-
42-
```javascript
43-
const dotenvPlugin = require('cypress-dotenv');
44-
module.exports = (on, config) => {
45-
config = dotenvPlugin(config)
46-
return config
47-
}
48-
```
42+
Version 3.x of this plugin only supports Cypress v10+. For instructions on how to set up this plugin with older versions of Cypress, please refer to the [v2.x README](https://github.com/morficus/cypress-dotenv/tree/v2.0.2?tab=readme-ov-file#configure)
4943

50-
Cypress (>= 10.0.0)
5144

52-
According to [Migration Guide](https://docs.cypress.io/guides/references/migration-guide#Plugins-File-Removed):
53-
The setupNodeEvents() config option is functionally equivalent to the function exported from the plugins file
45+
Since this is a plugin, you will need to modify your `cypress.config.js` to look something like this
5446

55-
```javascript
47+
```typescript
5648
import { defineConfig } from 'cypress'
5749
import dotenvPlugin from 'cypress-dotenv'
5850

5951
export default defineConfig({
60-
e2e: {
61-
...
62-
setupNodeEvents(on, config) {
63-
return dotenvPlugin(config)
64-
},
52+
e2e: {
53+
...
54+
setupNodeEvents(on, config) {
55+
const updatedConfig = dotenvPlugin(config, null, true)
56+
// continue loading other plugins
57+
return updatedConfig
58+
},
6559
},
6660
...
6761
})
6862
```
6963

70-
## Options
71-
This plugin takes three paramaters. The first parameter (which is mandatory) is the Cypress config object.
7264

73-
The second is an optional [dotenv](https://www.npmjs.com/package/dotenv#config) config object.
7465

75-
The third is an optional [all] boolean parameter, which is set to false by default. If set to true, it returns all available environmental variables, not limited to those prefixed with CYPRESS_.
66+
## Options
67+
This plugin takes three parameters:
68+
69+
1. The first parameter (which is mandatory) is the Cypress config object.
70+
1. The second is an optional [dotenv](https://www.npmjs.com/package/dotenv#config) config object.
71+
1. The third (called `all`) is an optional boolean parameter, which is set to false by default. If set to true, it returns all available environmental variables, not limited to those prefixed with CYPRESS_.

cypress.config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const { defineConfig } = require('cypress')
2+
const dotenvPlugin = require('./index')
3+
4+
module.exports = defineConfig({
5+
video: false,
6+
e2e: {
7+
// We've imported your old cypress plugins here.
8+
// You may want to clean this up later by importing these.
9+
setupNodeEvents(on, config) {
10+
const updatedConfig = dotenvPlugin(config, null, true)
11+
// continue loading other plugins
12+
13+
return updatedConfig
14+
}
15+
}
16+
})

cypress.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

cypress/plugins/index.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)