feat(core): add option to skip serve step for cypress builder

The builder currently supports skipping the serve step by passing an empty value
for
devServerTarget. This is not intuitive and makes configuring this via the command line messy.
This
flag has the same behavior as passing an empty devServerTarget but is more user-friendly.
This
option can be useful for CI purposes where applications are previously built and want to use
the
same configuration for e2e testing but the serve step is unnecessary.

ISSUES CLOSED: #3744
This commit is contained in:
Zachary Williams 2021-03-05 13:39:21 -06:00 committed by Victor Savkin
parent 8088f20df7
commit 564a86e096
6 changed files with 56 additions and 2 deletions

View File

@ -104,6 +104,14 @@ Type: `string`
The reporter options used. Supported options depend on the reporter. The reporter options used. Supported options depend on the reporter.
### skipServe
Default: `false`
Type: `boolean`
Skip dev-server build.
### spec ### spec
Type: `string` Type: `string`

View File

@ -105,6 +105,14 @@ Type: `string`
The reporter options used. Supported options depend on the reporter. The reporter options used. Supported options depend on the reporter.
### skipServe
Default: `false`
Type: `boolean`
Skip dev-server build.
### spec ### spec
Type: `string` Type: `string`

View File

@ -105,6 +105,14 @@ Type: `string`
The reporter options used. Supported options depend on the reporter. The reporter options used. Supported options depend on the reporter.
### skipServe
Default: `false`
Type: `boolean`
Skip dev-server build.
### spec ### spec
Type: `string` Type: `string`

View File

@ -22,15 +22,17 @@ describe('Cypress builder', () => {
record: false, record: false,
baseUrl: undefined, baseUrl: undefined,
watch: false, watch: false,
skipServe: false,
}; };
let mockContext; let mockContext;
let mockedInstalledCypressVersion: jest.Mock< let mockedInstalledCypressVersion: jest.Mock<
ReturnType<typeof installedCypressVersion> ReturnType<typeof installedCypressVersion>
> = installedCypressVersion as any; > = installedCypressVersion as any;
mockContext = { root: '/root', workspace: { projects: {} } } as any; mockContext = { root: '/root', workspace: { projects: {} } } as any;
let runExecutor: any;
beforeEach(async () => { beforeEach(async () => {
(devkit as any).runExecutor = jest.fn().mockReturnValue([ runExecutor = (devkit as any).runExecutor = jest.fn().mockReturnValue([
{ {
success: true, success: true,
baseUrl: 'http://localhost:4200', baseUrl: 'http://localhost:4200',
@ -172,6 +174,7 @@ describe('Cypress builder', () => {
record: false, record: false,
baseUrl: undefined, baseUrl: undefined,
watch: false, watch: false,
skipServe: false,
}, },
mockContext mockContext
); );
@ -261,4 +264,25 @@ describe('Cypress builder', () => {
); );
done(); done();
}); });
it('should call `Cypress.run` without serving the app', async (done) => {
const { success } = await cypressExecutor(
{
...cypressOptions,
skipServe: true,
baseUrl: 'http://my-distant-host.com',
},
mockContext
);
expect(success).toEqual(true);
expect(runExecutor).not.toHaveBeenCalled();
expect(cypressRun).toHaveBeenCalledWith(
jasmine.objectContaining({
config: {
baseUrl: 'http://my-distant-host.com',
},
})
);
done();
});
}); });

View File

@ -32,6 +32,7 @@ export interface CypressExecutorOptions extends Json {
ignoreTestFiles?: string; ignoreTestFiles?: string;
reporter?: string; reporter?: string;
reporterOptions?: string; reporterOptions?: string;
skipServe: boolean;
} }
try { try {
@ -106,7 +107,7 @@ async function* startDevServer(
context: ExecutorContext context: ExecutorContext
) { ) {
// no dev server, return the provisioned base url // no dev server, return the provisioned base url
if (!opts.devServerTarget) { if (!opts.devServerTarget || opts.skipServe) {
yield opts.baseUrl; yield opts.baseUrl;
return; return;
} }

View File

@ -86,6 +86,11 @@
"reporterOptions": { "reporterOptions": {
"type": "string", "type": "string",
"description": "The reporter options used. Supported options depend on the reporter." "description": "The reporter options used. Supported options depend on the reporter."
},
"skipServe": {
"type": "boolean",
"description": "Skip dev-server build.",
"default": false
} }
}, },
"additionalProperties": true, "additionalProperties": true,