Skip to content

Commit

Permalink
feat: support Cypress project flag (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
danadajian authored Jul 8, 2022
1 parent c317fdf commit 9c7d37a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ setupNodeEvents(on, config) {

## Configuration

### Project Flag

If you are using the `--project` flag when starting Cypress, you will need to set the Cypress environment variable `PROJECT` to your project name.

In cypress.config.ts:

```ts
env: {
PROJECT: 'my-project';
}
```

### Javascript

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

or in `cypress.json`:
or in `cypress.config.js`:

```json
{
"env": {
"CODEGEN": false
}
```ts
env: {
CODEGEN: false;
}
```
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ before('Import Custom Commands', () => {
cy.task('importCustomCommands').then(
({ filePaths, commandsDirectory }: { filePaths: string[]; commandsDirectory: string }) => {
filePaths.forEach(filePath => {
const projectName = Cypress.env('PROJECT') ? `${Cypress.env('PROJECT')}/` : '';
// This relative file path is extremely particular and for some unknown reason must be exactly this.
const customCommandObject = require(`../../../cypress/commands/${filePath.replace(
const customCommandObject = require(`../../../${projectName}cypress/commands/${filePath.replace(
commandsDirectory,
''
)}`);
Expand Down

0 comments on commit 9c7d37a

Please sign in to comment.