Skip to content

Commit

Permalink
Merge branch 'develop' into issue-17415
Browse files Browse the repository at this point in the history
  • Loading branch information
flotwig authored Jul 30, 2021
2 parents c371b71 + 13f792c commit 3d0c1b2
Show file tree
Hide file tree
Showing 21 changed files with 81 additions and 34 deletions.
6 changes: 3 additions & 3 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1270,9 +1270,6 @@ jobs:
- run:
name: Build
command: yarn workspace @cypress/webpack-preprocessor build
- run:
name: Run tests
command: yarn workspace @cypress/webpack-preprocessor test
- run:
name: Test babelrc
command: yarn test
Expand All @@ -1298,6 +1295,9 @@ jobs:
name: Test React app
command: yarn test
working_directory: npm/webpack-preprocessor/examples/react-app
- run:
name: Run tests
command: yarn workspace @cypress/webpack-preprocessor test
- store-npm-logs

npm-webpack-dev-server:
Expand Down
2 changes: 1 addition & 1 deletion cli/types/cypress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1661,7 +1661,7 @@ declare namespace Cypress {
* .shadow()
* .find('.my-button')
* .click()
* @see https://on.cypress.io/experimental
* @see https://on.cypress.io/shadow
*/
shadow(): Chainable<Subject>

Expand Down
7 changes: 7 additions & 0 deletions npm/vite-dev-server/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [@cypress/vite-dev-server-v2.0.3](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v2.0.2...@cypress/vite-dev-server-v2.0.3) (2021-07-27)


### Bug Fixes

* make vite re-run on supportFile change ([#17485](https://github.com/cypress-io/cypress/issues/17485)) ([6cbf4c3](https://github.com/cypress-io/cypress/commit/6cbf4c38296d6287fbcbb0ef5ecd21cf63606153))

# [@cypress/vite-dev-server-v2.0.2](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v2.0.1...@cypress/vite-dev-server-v2.0.2) (2021-07-15)


Expand Down
3 changes: 3 additions & 0 deletions npm/vite-dev-server/cypress/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
color: indigo;
}
1 change: 1 addition & 0 deletions npm/vite-dev-server/cypress/support.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import '@testing-library/cypress/add-commands'
import './styles.css'

before(() => {
window.supportFileWasLoaded = true
Expand Down
10 changes: 5 additions & 5 deletions npm/vite-dev-server/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { debug as debugFn } from 'debug'
import { start as createDevServer, StartDevServer } from './startServer'
import { start as createDevServer, StartDevServerOptions } from './startServer'
const debug = debugFn('cypress:vite-dev-server:vite')

export { StartDevServer }
export { StartDevServerOptions }

type DoneCallback = () => unknown

Expand All @@ -11,13 +11,13 @@ export interface ResolvedDevServerConfig {
close: (done?: DoneCallback) => void
}

export async function startDevServer (startDevServerArgs: StartDevServer): Promise<ResolvedDevServerConfig> {
export async function startDevServer (startDevServerArgs: StartDevServerOptions): Promise<ResolvedDevServerConfig> {
const viteDevServer = await createDevServer(startDevServerArgs)

const app = await viteDevServer.listen()
const port = app.config.server.port
const port = app.config.server.port!

debug('Component testing vite server started on port', port)

return { port, close: app.httpServer.close }
return { port, close: app.httpServer!.close }
}
15 changes: 10 additions & 5 deletions npm/vite-dev-server/src/makeCypressPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ const INIT_FILEPATH = resolve(__dirname, '../client/initCypressTests.js')

const HMR_DEPENDENCY_LOOKUP_MAX_ITERATION = 50

function getSpecsSet (specs: Spec[]) {
return new Set<string>(specs.map((spec) => spec.absolute))
function getSpecsPathsSet (specs: Spec[], supportFile?: string | null) {
return new Set<string>(
supportFile
? [...specs.map((spec) => spec.absolute), supportFile]
: specs.map((spec) => spec.absolute),
)
}

interface Spec{
Expand All @@ -38,10 +42,10 @@ export const makeCypressPlugin = (
): Plugin => {
let base = '/'

let specsPathsSet = getSpecsSet(specs)
let specsPathsSet = getSpecsPathsSet(specs, supportFilePath)

devServerEvents.on('dev-server:specs:changed', (specs: Spec[]) => {
specsPathsSet = getSpecsSet(specs)
specsPathsSet = getSpecsPathsSet(specs, supportFilePath)
})

const posixSupportFilePath = supportFilePath ? convertPathToPosix(resolve(projectRoot, supportFilePath)) : undefined
Expand Down Expand Up @@ -101,7 +105,8 @@ export const makeCypressPlugin = (

// as soon as we find one of the specs, we trigger the re-run of tests
for (const mod of moduleImporters.values()) {
if (specsPathsSet.has(mod.file)) {
debug('handleHotUpdate - mod.file', mod.file)
if (mod.file && specsPathsSet.has(mod.file)) {
debug('handleHotUpdate - compile success')
devServerEvents.emit('dev-server:compile:success', { specFile: mod.file })

Expand Down
8 changes: 4 additions & 4 deletions npm/vite-dev-server/src/startServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface Options {
[key: string]: unknown
}

export interface StartDevServer {
export interface StartDevServerOptions {
/**
* the Cypress options object
*/
Expand All @@ -27,7 +27,7 @@ export interface StartDevServer {
viteConfig?: UserConfig
}

const resolveServerConfig = async ({ viteConfig, options }: StartDevServer): Promise<InlineConfig> => {
const resolveServerConfig = async ({ viteConfig, options }: StartDevServerOptions): Promise<InlineConfig> => {
const { projectRoot, supportFile } = options.config

const requiredOptions: InlineConfig = {
Expand All @@ -37,7 +37,7 @@ const resolveServerConfig = async ({ viteConfig, options }: StartDevServer): Pro

const finalConfig: InlineConfig = { ...viteConfig, ...requiredOptions }

finalConfig.plugins = [...(viteConfig.plugins || []), makeCypressPlugin(projectRoot, supportFile, options.devServerEvents, options.specs)]
finalConfig.plugins = [...(finalConfig.plugins || []), makeCypressPlugin(projectRoot, supportFile, options.devServerEvents, options.specs)]

// This alias is necessary to avoid a "prefixIdentifiers" issue from slots mounting
// only cjs compiler-core accepts using prefixIdentifiers in slots which vue test utils use.
Expand Down Expand Up @@ -66,7 +66,7 @@ const resolveServerConfig = async ({ viteConfig, options }: StartDevServer): Pro
return finalConfig
}

export async function start (devServerOptions: StartDevServer): Promise<ViteDevServer> {
export async function start (devServerOptions: StartDevServerOptions): Promise<ViteDevServer> {
if (!devServerOptions.viteConfig) {
debug('User did not pass in any Vite dev server configuration')
devServerOptions.viteConfig = {}
Expand Down
2 changes: 1 addition & 1 deletion npm/vite-dev-server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */

/* Strict Type-Checking Options */
"strict": false /* Enable all strict type-checking options. */,
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": false,

/* Module Resolution Options */
Expand Down
7 changes: 7 additions & 0 deletions npm/vue/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [@cypress/vue-v3.0.0-beta.4](https://github.com/cypress-io/cypress/compare/@cypress/vue-v3.0.0-beta.3...@cypress/vue-v3.0.0-beta.4) (2021-07-27)


### Bug Fixes

* do not register CT specific event in e2e mode ([5836203](https://github.com/cypress-io/cypress/commit/58362037fd231c6fdc587e422fc139bf7546ac2d))

# [@cypress/vue-v3.0.0-beta.3](https://github.com/cypress-io/cypress/compare/@cypress/vue-v3.0.0-beta.2...@cypress/vue-v3.0.0-beta.3) (2021-06-24)


Expand Down
4 changes: 2 additions & 2 deletions npm/webpack-preprocessor/__snapshots__/compilation.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
exports['webpack preprocessor - e2e correctly preprocesses the file 1'] = `
it("is a test",(function(){expect(1).to.equal(1),expect(2).to.equal(2),expect(Math.min.apply(Math,[3,4])).to.equal(3)}));
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly9AY3lwcmVzcy93ZWJwYWNrLXByZXByb2Nlc3Nvci8uL3Rlc3QvX3Rlc3Qtb3V0cHV0L2V4YW1wbGVfc3BlYy5qcyJdLCJuYW1lcyI6WyJpdCIsImV4cGVjdCIsInRvIiwiZXF1YWwiLCJNYXRoIiwibWluIl0sIm1hcH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N0KE1hdGgubWluKC4uLlszLCA0XSkpLnRvLmVxdWFsKDMpXG59KVxuIl0sIm5hbWVzIjpbIml0IiwiZXhwZWN0IiwidG8iLCJlcXVhbCIsIk1hdGgiLCJtaW4iXSwic291cmNlUm9vdCI6IiJ9
`

exports['webpack preprocessor - e2e has less verbose syntax error 1'] = `
Expand All @@ -16,4 +16,4 @@ SyntaxError: <path>/_test-output/syntax_error_spec.js: Unexpected token (1:18)
exports['webpack preprocessor - e2e has less verbose "Module not found" error 1'] = `
Webpack Compilation Error
Module not found: Error: Can't resolve './does/not-exist' in '<path>/_test-output'
`
`
2 changes: 1 addition & 1 deletion npm/webpack-preprocessor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"secure": "nsp check",
"semantic-release": "semantic-release",
"size": "npm pack --dry",
"test": "node ./test-webpack-4-5.js",
"test": "node ./test-webpack-5.js",
"test-debug": "node --inspect --debug-brk ./node_modules/.bin/_mocha",
"test-e2e": "mocha test/e2e/*.spec.*",
"test-unit": "mocha test/unit/*.spec.*",
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cypress",
"version": "8.0.0",
"version": "8.1.0",
"description": "Cypress.io end to end testing tool",
"private": true,
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const onSubmitNewProject = function (orgId) {
.contains('.btn', 'Set up project').click()
.then(() => {
expect(this.ipc.setupDashboardProject).to.be.calledWith({
projectRoot: '/foo/bar',
projectName: this.config.projectName,
orgId,
public: false,
Expand All @@ -21,6 +22,7 @@ const onSubmitNewProject = function (orgId) {
.then(() => {
expect(this.ipc.setupDashboardProject).to.be.calledWith({
projectName: 'New Project',
projectRoot: '/foo/bar',
orgId,
public: true,
})
Expand Down Expand Up @@ -114,7 +116,7 @@ describe('Connect to Dashboard', function () {
cy.stub(this.ipc, 'getRecordKeys').resolves(this.keys)
cy.stub(this.ipc, 'pingApiServer').resolves()
cy.stub(this.ipc, 'externalOpen')
cy.stub(this.ipc, 'setProjectId').resolvesArg(0)
cy.stub(this.ipc, 'setProjectId').callsFake((arg) => Promise.resolve(arg.id))
cy.stub(this.ipc, 'beginAuth').resolves()

this.getCurrentUser = this.util.deferred()
Expand Down Expand Up @@ -485,7 +487,7 @@ describe('Connect to Dashboard', function () {
cy.get('.setup-project')
.contains('.btn', 'Set up project').click()
.then(() => {
expect(this.ipc.setProjectId).to.be.calledWith(this.dashboardProjects[1].id)
expect(this.ipc.setProjectId).to.be.calledWith({ id: this.dashboardProjects[1].id, projectRoot: '/foo/bar' })
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ const setupDashboardProject = (projectDetails) => {
.catch(ipc.isUnauthed, ipc.handleUnauthed)
}

const setProjectId = (id) => {
return ipc.setProjectId(id)
const setProjectId = (id, projectRoot) => {
return ipc.setProjectId({ id, projectRoot })
}

export default {
Expand Down
4 changes: 2 additions & 2 deletions packages/desktop-gui/src/runs/runs-list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ class RunsList extends Component {

_getRecordKeys () {
if (this._needsKey()) {
projectsApi.getRecordKeys().then((keys = []) => {
if (keys.length) {
projectsApi.getRecordKeys().then((keys) => {
if (keys && keys.length) {
this.setState({ recordKey: keys[0].id })
}
})
Expand Down
3 changes: 2 additions & 1 deletion packages/desktop-gui/src/runs/setup-project.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,13 @@ class SetupProject extends Component {
if (this.state.newProject) {
return dashboardProjectsApi.setupDashboardProject({
projectName: this.state.projectName,
projectRoot: this.props.project.path,
orgId: this.state.selectedOrgId,
public: this.state.public,
})
}

return dashboardProjectsApi.setProjectId(this.state.selectedProjectId)
return dashboardProjectsApi.setProjectId(this.state.selectedProjectId, this.props.project.path)
.then((id) => {
const project = dashboardProjectsStore.getProjectById(id)

Expand Down
4 changes: 2 additions & 2 deletions packages/server/lib/gui/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,12 @@ const handleEvent = function (options, bus, event, id, type, arg) {
.catch(sendErr)

case 'setup:dashboard:project':
return ProjectStatic.createCiProject(arg, options.projectRoot)
return ProjectStatic.createCiProject(arg, arg.projectRoot)
.then(send)
.catch(sendErr)

case 'set:project:id':
return ProjectStatic.writeProjectId(arg, options.projectRoot)
return ProjectStatic.writeProjectId(arg.id, arg.projectRoot)
.then(send)
.catch(sendErr)

Expand Down
1 change: 1 addition & 0 deletions packages/server/lib/project_static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export async function writeProjectId (id: string, projectRoot: string) {

interface ProjectDetails {
projectName: string
projectRoot: string
orgId: string | null
public: boolean
}
Expand Down
24 changes: 22 additions & 2 deletions packages/server/test/unit/gui/events_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -923,9 +923,28 @@ describe('lib/gui/events', () => {
})
})

describe('set:project:id', () => {
it('calls writeProjectId with projectRoot', function () {
const arg = { id: '1', projectRoot: '/project/root/' }
const stub = sinon.stub(ProjectStatic, 'writeProjectId').resolves()

return this.handleEvent('set:project:id', arg)
.then(() => {
expect(stub).to.be.calledWith(arg.id, arg.projectRoot)
expect(this.send.firstCall.args[0]).to.eq('response')
expect(this.send.firstCall.args[1].id).to.match(/set:project:id-/)
})
})
})

describe('setup:dashboard:project', () => {
it('returns result of ProjectStatic.createCiProject', function () {
return this.handleEvent('setup:dashboard:project').then((assert) => {
const arg = { projectRoot: '/project/root/' }
const stub = sinon.stub(ProjectStatic, 'createCiProject').resolves()

return this.handleEvent('setup:dashboard:project', arg)
.then(() => {
expect(stub).to.be.calledWith(arg, arg.projectRoot)
expect(this.send.firstCall.args[0]).to.eq('response')
expect(this.send.firstCall.args[1].id).to.match(/setup:dashboard:project-/)
})
Expand All @@ -936,7 +955,8 @@ describe('lib/gui/events', () => {

sinon.stub(ProjectStatic, 'createCiProject').rejects(err)

return this.handleEvent('setup:dashboard:project').then((assert) => {
return this.handleEvent('setup:dashboard:project', { projectRoot: '/foo/bar' })
.then((assert) => {
return assert.sendErrCalledWith(err)
})
})
Expand Down

0 comments on commit 3d0c1b2

Please sign in to comment.