Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into cy-session
Browse files Browse the repository at this point in the history
  • Loading branch information
kuceb committed Aug 2, 2021
2 parents c877359 + d5f1dc3 commit 64485d1
Show file tree
Hide file tree
Showing 44 changed files with 1,300 additions and 268 deletions.
15 changes: 14 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,20 @@
"rules": {
"prefer-spread": "off",
"prefer-rest-params": "off",
"no-useless-constructor": "off"
"no-useless-constructor": "off",
"no-restricted-properties": [
"error",
{
"object": "process",
"property": "geteuid",
"message": "process.geteuid() will throw on Windows. Do not use it unless you catch any potential errors."
},
{
"object": "os",
"property": "userInfo",
"message": "os.userInfo() will throw when there is not an `/etc/passwd` entry for the current user (like when running with --user 12345 in Docker). Do not use it unless you catch any potential errors."
}
]
},
"settings": {
"react": {
Expand Down
2 changes: 1 addition & 1 deletion browser-versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"chrome:beta": "92.0.4515.107",
"chrome:beta": "93.0.4577.18",
"chrome:stable": "92.0.4515.107"
}
4 changes: 4 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,10 @@ jobs:
- run:
name: Build
command: yarn workspace @cypress/vue build
- run:
name: Type Check
command: yarn typecheck
working_directory: npm/vue
- run:
name: Run component tests
command: yarn test:ci:ct
Expand Down
1 change: 1 addition & 0 deletions cli/test/lib/tasks/verify_spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-properties */
require('../../spec_helper')

const path = require('path')
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
2 changes: 1 addition & 1 deletion npm/vue/.releaserc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ module.exports = {
// this line forces releasing 2.X releases on the latest channel
{ name: 'npm/vue/v2', range: '2.X.X' },
// this one releases v3 on master as beta on the next channel
{ name: 'master', channel: 'next', prerelease: 'beta' },
{ name: 'master', channel: 'next' },
],
}
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
22 changes: 21 additions & 1 deletion npm/vue/babel.config.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"browsers": [
"last 1 Chrome version",
"last 1 Electron version",
"last 1 Firefox version"
]
},
"modules": "cjs"
}
],
"babel-preset-typescript-vue3",
"@babel/preset-typescript"
],
"plugins": [
"@babel/plugin-transform-modules-commonjs",
[
"babel-plugin-istanbul",
{
"extension": [
".js",
".vue"
],
"exclude": [
"**/*.spec.{js,ts}",
"**/setup/*.vue"
]
}
]
Expand Down
2 changes: 1 addition & 1 deletion npm/vue/cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"video": false,
"responseTimeout": 2500,
"projectId": "134ej7",
"testFiles": "**/*spec.js",
"testFiles": "**/*spec.{js,ts,tsx}",
"experimentalFetchPolyfill": true
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference types="cypress" />
import Hello from './Hello.vue'
import { mount } from '@cypress/vue'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ describe('Props', () => {
it('has props', () => {
const messages = ['one 🍎', 'two 🍌']

mount(MessageList, { propsData: { messages } })
mount(MessageList, { props: { messages } })
getItems()
.should('have.length', 2)
.then((list) => {
expect(list[0].textContent.trim()).to.equal(messages[0])
expect(list[1].textContent.trim()).to.equal(messages[1])
expect(list[0].textContent).to.contain(messages[0])
expect(list[1].textContent).to.contain(messages[1])
})
})
})
Expand Down
27 changes: 27 additions & 0 deletions npm/vue/cypress/component/setup/HelloWorld-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { h } from 'vue'
import { mount } from '@cypress/vue'
import HelloWorld from './HelloWorld.vue'

describe('HelloWorld', () => {
it('normal mount', () => {
mount(HelloWorld, { props: { msg: 'Hello Cypress' } })
})

it('functional mount', () => {
mount(() => h(HelloWorld, { msg: 'Hello Cypress' }))
})

it('renders properly', () => {
mount(HelloWorld, { props: { msg: 'Hello Cypress' } })
cy.get('h1').should('contain', 'Hello Cypress')
})

it('adds 1 when clicking the plus button', () => {
mount(HelloWorld, { props: { msg: 'Hello Cypress' } })

cy.get('button')
.should('contain', '0')
.click()
.should('contain', '1')
})
})
12 changes: 12 additions & 0 deletions npm/vue/cypress/component/setup/HelloWorld.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<template>
<h1>{{ msg }}</h1>
<button type="button" @click="count++">count is: {{ count }}</button>
</template>

<script setup lang="ts">
import { defineProps, ref } from 'vue'
defineProps<{
msg: String,
}>()
const count = ref(0)
</script>
19 changes: 11 additions & 8 deletions npm/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,33 @@
"build-prod": "yarn build",
"cy:open": "node ../../scripts/cypress.js open-ct --project ${PWD}",
"cy:run": "node ../../scripts/cypress.js run-ct --project ${PWD}",
"test:ci:e2e": "node ../../scripts/cypress.js run --project ${PWD}",
"typecheck": "vue-tsc --noEmit",
"test": "yarn cy:run",
"watch": "yarn build --watch --watch.exclude ./dist/**/*",
"test:ci:e2e": "node ../../scripts/cypress.js run --project ${PWD}",
"test:ci:ct": "node ../../scripts/run-ct-examples.js --examplesList=./examples.env"
},
"dependencies": {
"@cypress/mount-utils": "0.0.0-development",
"@vue/test-utils": "^2.0.0-rc.9"
"@vue/test-utils": "^2.0.0-rc.10"
},
"devDependencies": {
"@babel/core": "7.9.0",
"@babel/plugin-transform-modules-commonjs": "7.10.4",
"@babel/plugin-transform-modules-commonjs": "7.9.6",
"@babel/preset-env": "7.9.5",
"@babel/preset-typescript": "7.10.1",
"@cypress/code-coverage": "3.8.1",
"@cypress/webpack-dev-server": "0.0.0-development",
"@intlify/vue-i18n-loader": "2.0.0-rc.1",
"@rollup/plugin-commonjs": "^17.1.0",
"@rollup/plugin-node-resolve": "^11.1.1",
"@vue/cli-plugin-babel": "~4.4.0",
"@vue/cli-service": "~4.4.0",
"@vue/compiler-sfc": "^3.0.5",
"@vue/compiler-sfc": "3.1.5",
"axios": "0.19.2",
"babel-loader": "8.1.0",
"babel-plugin-istanbul": "6.0.0",
"babel-plugin-istanbul": "^6.0.0",
"babel-preset-typescript-vue3": "^2.0.14",
"css-loader": "3.4.2",
"cypress": "0.0.0-development",
"debug": "4.3.2",
Expand All @@ -44,12 +47,13 @@
"rollup-plugin-istanbul": "2.0.1",
"rollup-plugin-typescript2": "^0.29.0",
"tailwindcss": "1.1.4",
"typescript": "3.9.6",
"vue": "3.0.11",
"typescript": "^4.2.3",
"vue": "3.1.5",
"vue-i18n": "9.0.0-rc.6",
"vue-loader": "16.1.2",
"vue-router": "^4.0.0",
"vue-style-loader": "4.1.2",
"vue-tsc": "0.2.2",
"vuex": "^4.0.0",
"webpack": "4.42.0"
},
Expand Down Expand Up @@ -77,7 +81,6 @@
"cypress",
"vue"
],
"unpkg": "dist/cypress-vue.browser.js",
"module": "dist/cypress-vue.esm-bundler.js",
"peerDependenciesMeta": {
"@cypress/webpack-dev-server": {
Expand Down
Loading

0 comments on commit 64485d1

Please sign in to comment.