Skip to content

Commit 9c7d37a

Browse files
authored
feat: support Cypress project flag (#27)
1 parent c317fdf commit 9c7d37a

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,18 @@ setupNodeEvents(on, config) {
9090

9191
## Configuration
9292

93+
### Project Flag
94+
95+
If you are using the `--project` flag when starting Cypress, you will need to set the Cypress environment variable `PROJECT` to your project name.
96+
97+
In cypress.config.ts:
98+
99+
```ts
100+
env: {
101+
PROJECT: 'my-project';
102+
}
103+
```
104+
93105
### Javascript
94106

95107
The IntelliSense codegen feature is enabled by default.
@@ -100,12 +112,10 @@ You will still get the benefit of the custom commands being loaded automatically
100112
CYPRESS_CODEGEN=false npx cypress run
101113
```
102114

103-
or in `cypress.json`:
115+
or in `cypress.config.js`:
104116

105-
```json
106-
{
107-
"env": {
108-
"CODEGEN": false
109-
}
117+
```ts
118+
env: {
119+
CODEGEN: false;
110120
}
111121
```

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ before('Import Custom Commands', () => {
1717
cy.task('importCustomCommands').then(
1818
({ filePaths, commandsDirectory }: { filePaths: string[]; commandsDirectory: string }) => {
1919
filePaths.forEach(filePath => {
20+
const projectName = Cypress.env('PROJECT') ? `${Cypress.env('PROJECT')}/` : '';
2021
// This relative file path is extremely particular and for some unknown reason must be exactly this.
21-
const customCommandObject = require(`../../../cypress/commands/${filePath.replace(
22+
const customCommandObject = require(`../../../${projectName}cypress/commands/${filePath.replace(
2223
commandsDirectory,
2324
''
2425
)}`);

0 commit comments

Comments
 (0)