Skip to content

Commit

Permalink
feat: add recordServiceUrl config option
Browse files Browse the repository at this point in the history
  • Loading branch information
agoldis committed Mar 8, 2023
1 parent 8afee11 commit 18c1dbd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ Install the package
npm install @currents/cypress
```

Create a new configuration file: `currents.config.js` in the project’s root and set the `projectId` and the record key obtained from [Currents](https://app.currents.dev) or your self-hosted instance of Sorry Cypress:
Create a new configuration file: `currents.config.js` in the project’s root, set the `projectId` and the record key obtained from [Currents](https://app.currents.dev) or your self-hosted instance of Sorry Cypress:

```js
module.exports = {
projectId: "Ij0RfK",
recordKey: "xxx",
cloudServiceUrl: "https://cy.currents.dev", // Sorry Cypress users - set the director service URL
};
```

Expand All @@ -38,16 +39,14 @@ const { cloudPlugin } = require("@currents/cypress/plugin");
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
cloudPlugin(on, config);
return cloudPlugin(on, config);
},
},
});
```

## Usage

Obtain the record key from https://app.currents.dev (or use any value for Sorry Cypress)

```sh
npx cypress-cloud --parallel --record --key <your_key> --ci-build-id hello-cypress-cloud
```
Expand All @@ -63,8 +62,15 @@ See an example in [examples/webapp](./example/webapp) directory
```js
// currents.config.js
module.exports = {
projectId: "Ij0RfK",
recordKey: "the record key from currents.dev",
projectId: "Ij0RfK", // ProjectID obtained from https://app.currents.dev or Sorry Cypress
recordKey: "XXXXXXX", // Record key obtained from https://app.currents.dev, any value for Sorry Cypress
cloudServiceUrl: "https://cy.currents.dev", // Sorry Cypress users - the director service URL
e2e: {
batchSize: 3, // orchestration batch size for e2e tests
},
component: {
batchSize: 5, // orchestration batch size for component tests
},
};
```

Expand Down Expand Up @@ -105,12 +111,14 @@ const results = await run({

## Troubleshooting

Enable the debug mode and run the command
Enable the debug mode and run the command:

```sh
DEBUG=currents:* npx cypress-cloud run ...
```

Capture all the logs in a plain text file and submit an issue.

## Testing

```sh
Expand Down
5 changes: 0 additions & 5 deletions examples/webapp/currents-runner.sh

This file was deleted.

6 changes: 4 additions & 2 deletions packages/cypress-cloud/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ export type ComponentConfig = {
export type CurrentsConfig = {
projectId?: string;
recordKey?: string;
cloudServiceUrl?: string;
e2e: E2EConfig;
component: ComponentConfig;
};

export async function getCurrentsConfig(): Promise<CurrentsConfig> {
const configFilePath = await getConfigFilePath();
export function getCurrentsConfig(): CurrentsConfig {
const configFilePath = getConfigFilePath();
debug("loading currents config file from '%s'", configFilePath);

const defaultConfig: CurrentsConfig = {
Expand All @@ -30,6 +31,7 @@ export async function getCurrentsConfig(): Promise<CurrentsConfig> {
component: {
batchSize: 5,
},
cloudServiceUrl: "https://cy.currents.dev",
};

try {
Expand Down
5 changes: 4 additions & 1 deletion packages/cypress-cloud/lib/httpClient/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AxiosError, isAxiosError } from "axios";
import { getCurrentsConfig } from "../config";

export const isRetriableError = (err: AxiosError): boolean => {
if (!isAxiosError(err)) {
Expand All @@ -17,4 +18,6 @@ export const isRetriableError = (err: AxiosError): boolean => {
export const getDelay = (i: number) => [15 * 1000, 30 * 1000, 60 * 1000][i - 1];

export const getBaseUrl = () =>
process.env.CURRENTS_API_URL || "https://cy.currents.dev";
process.env.CURRENTS_API_URL ??
getCurrentsConfig().cloudServiceUrl ??
"https://cy.currents.dev";

0 comments on commit 18c1dbd

Please sign in to comment.