Skip to content

Commit

Permalink
Merge branch 'master' into 'fix/make-imported-cypress/react-work'
Browse files Browse the repository at this point in the history
  • Loading branch information
dmtrKovalenko committed Oct 13, 2020
2 parents 49dfab8 + ff5244a commit e39ffd6
Show file tree
Hide file tree
Showing 18 changed files with 116 additions and 530 deletions.
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE/component-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ assignees: JessicaSachs
<!-- 👋 Hello! -->
<!-- Cypress Component Testing is still in Alpha, so your feature requests and bug reports will help shape the future of the library. -->

<!-- We're growing the Cypress Community Discord. We have dedicated sections on Component Testing. Join now and let's chat! 👉 https://discord.com/invite/TmzTGUW -->

### Summary
<!-- Summarize the issue or feature request. -->
<!-- This is also where you add additional context for the bug or feature, such as what the issue prevents you from achieving or what the proposed feature may enable to you accomplish -->
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/merge-master-into-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ jobs:
with:
fetch-depth: 0
token: ${{ secrets.DEVELOP_PUSH_TOKEN }}
- name: Checkout develop branch
run: git checkout develop
- name: Set committer info
run: |
git config --local user.email "$(git log --format='%ae' HEAD^!)"
git config --local user.name "$(git log --format='%an' HEAD^!)"
- name: Checkout develop branch
run: git checkout develop
- name: Check for merge conflict
id: check-conflict
run: echo "::set-output name=merge_conflict::$(git merge-tree $(git merge-base HEAD master) master HEAD | egrep '<<')"
Expand Down
11 changes: 0 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ binary-url.json
.eslintrc.js
cli/visual-snapshots


# Created by https://www.gitignore.io/api/osx,git,node,windows,intellij,linux
# Edit at https://www.gitignore.io/?templates=osx,git,node,windows,intellij,linux

Expand All @@ -54,16 +53,6 @@ cli/visual-snapshots
# $ git config --global mergetool.keepBackup false
*.orig

# Created by git when using merge tools for conflicts
*.BACKUP.*
*.BASE.*
*.LOCAL.*
*.REMOTE.*
*_BACKUP_*.txt
*_BASE_*.txt
*_LOCAL_*.txt
*_REMOTE_*.txt

### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
Expand Down
19 changes: 19 additions & 0 deletions .releaserc.base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
['@semantic-release/changelog', {
changelogFile: 'CHANGELOG.md',
}],
['@semantic-release/git', {
assets: [
'**/CHANGELOG.md',
],
message: 'chore: release ${nextRelease.gitTag}\n\n[skip ci]',
}],
'@semantic-release/npm',
],
extends: 'semantic-release-monorepo',
branches: [
],
}
6 changes: 6 additions & 0 deletions .releaserc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
...require('./.releaserc.base'),
branches: [
'master',
],
}
11 changes: 0 additions & 11 deletions .releaserc.json

This file was deleted.

7 changes: 7 additions & 0 deletions npm/vue/.releaserc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
...require('../../.releaserc.base'),
branches: [
'@cypress/vue@1.0.0',
{ name: 'master', prerelease: 'alpha' },
],
}
8 changes: 7 additions & 1 deletion npm/vue/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
[![renovate-app badge][renovate-badge]][renovate-app]

> Browser-based Component Testing for Vue.js with the Open-Source [Cypress.io](https://www.cypress.io/) Test Runner ✌️🌲
>
**✨ New** We're growing the Cypress Community Discord. We have dedicated sections on Component Testing. 👉 [Join now](https://discord.com/invite/TmzTGUW) and let's chat!

**Jump to:** [Comparison](#comparison), [Blog posts](#blog-posts), Examples: [basic](#basic-examples), [advanced](#advanced-examples), [full](#full-examples), [external](#external-examples), [Code coverage](#code-coverage), [Development](#development)

**🚧 Notice** We are in the middle of moving into the Cypress NPM org, so any references to `@cypress/vue` should be switched to `@cypress/vue`. Once complete, this repository will be archived.
**🚧 Notice** We are in the middle of moving into the Cypress NPM org, so any references to `cypress-vue-unit-test` should be switched to `@cypress/vue`. Once complete, this repository will be archived.

### What is @cypress/vue?
This package allows you to use the [Cypress](https://www.cypress.io/) test runner to mount and test your components within Cypress. It is built on top of the [Vue Test Utils](https://github.com/vuejs/vue-test-utils) package.
Expand Down Expand Up @@ -653,6 +655,10 @@ If you want to disable code coverage instrumentation and reporting, use `--env c

**Note ⚠️:** if the component `.vue` file does not have a `<script>` section, it will not have any code coverage information.

## What happened to cypress-vue-unit-test?

We were in the middle of moving into the Cypress NPM org, so any references to `cypress-vue-unit-test` should be switched to `@cypress/vue`. Once complete, the old repository will be archived.

<a name="#development"/>

## Development
Expand Down
2 changes: 1 addition & 1 deletion npm/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"babel-loader": "8.1.0",
"ban-sensitive-files": "1.9.7",
"css-loader": "3.4.2",
"cypress": "5.2.0",
"cypress": "*",
"dependency-check": "3.4.1",
"deps-ok": "1.4.1",
"eslint-plugin-vue": "^6.2.2",
Expand Down
72 changes: 0 additions & 72 deletions npm/webpack-preprocessor/__snapshots__/e2e.spec.js

This file was deleted.

151 changes: 0 additions & 151 deletions npm/webpack-preprocessor/test/e2e/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,9 @@ const Debug = require('debug')
const chalk = require('chalk')
const stripAnsi = require('strip-ansi')
const cypress = require('cypress')

const debug = Debug('test')
const rootDir = process.cwd()

const stackTraceLinesRe = /(\n?[^\S\n\r]*).*?(@|\bat\b).*\.(js|coffee|ts|html|jsx|tsx)(-\d+)?:\d+:\d+[\n\S\s]*?(\n\s*?\n|$)/g
const browserNameVersionRe = /(Browser\:\s+)(Custom |)(Electron|Chrome|Canary|Chromium|Firefox)(\s\d+)(\s\(\w+\))?(\s+)/
const availableBrowsersRe = /(Available browsers found are: )(.+)/g
const crossOriginErrorRe = /(Blocked a frame .* from accessing a cross-origin frame.*|Permission denied.*cross-origin object.*)/gm

const cp = require('child_process')

const _spawn = cp.spawn
Expand Down Expand Up @@ -60,7 +54,6 @@ exports.runTest = async (options = {}) => {
}

const opts = _.defaults(options, {
snapshot: true,
spec: '',
expectedResults: {
totalFailed: 0,
Expand All @@ -80,9 +73,6 @@ exports.runTest = async (options = {}) => {

const stdio = captureStdio(process.stdout)

stdio.passThrough((v) => chalk.magenta(stripAnsi(v.toString())))
// const stdio2 = captureStdio(process.stdout)

let stdout

_.extend(process.env, {
Expand Down Expand Up @@ -123,9 +113,6 @@ exports.runTest = async (options = {}) => {

// console.log(stdout)
console.log(`${chalk.bold('run matched these results:')} ${JSON.stringify(opts.expectedResults, null, 2)}`)
if (opts.snapshot) {
snapshot(normalizeStdout(stdout))
}
})
}

Expand Down Expand Up @@ -239,151 +226,13 @@ const captureStdio = (stdio, tty) => {
if (tty !== undefined) stdio.isTTY = tty

return {

passThrough (fn) {
passThrough = fn
},

data: logs,

reset: () => (logs = []),

toString: () => {
return stripAnsi(logs.join(''))
},

toStringRaw: () => {
return logs.join('')
},

restore () {
stdio.write = write
stdio.isTTY = isTTY
},
}
}

exports.captureStdio = captureStdio

const snapshot = require('snap-shot-it')

function replaceStackTraceLines (str) {
return str.replace(stackTraceLinesRe, (match, ...parts) => {
let pre = parts[0]
const isFirefoxStack = parts[1] === '@'
let post = parts[4]

if (isFirefoxStack) {
if (pre === '\n') {
pre = '\n '
} else {
pre += pre.slice(1).repeat(2)
}

post = post.slice(-1)
}

return `${pre}[stack trace lines]${post}`
})
}

function normalizeStdout (str, options = {}) {
const { normalizeStdoutAvailableBrowsers } = options

// remove all of the dynamic parts of stdout
// to normalize against what we expected
str = str
// /Users/jane/........../ -> //foo/bar/.projects/
// (Required when paths are printed outside of our own formatting)
.split(process.cwd()).join('/[cwd]')
// also normalize paths to the workspace root
.split(path.resolve(process.cwd(), '../..')).join('/[root]')

// unless normalization is explicitly turned off then
// always normalize the stdout replacing the browser text
if (normalizeStdoutAvailableBrowsers !== false) {
// usually we are not interested in the browsers detected on this particular system
// but some tests might filter / change the list of browsers
// in that case the test should pass "normalizeStdoutAvailableBrowsers: false" as options
str = str.replace(availableBrowsersRe, '$1browser1, browser2, browser3')
}

const replaceBrowserName = function (str, key, customBrowserPath, browserName, version, headless, whitespace) {
// get the padding for the existing browser string
const lengthOfExistingBrowserString = _.sum([browserName.length, version.length, _.get(headless, 'length', 0), whitespace.length])

// this ensures we add whitespace so the border is not shifted
return key + customBrowserPath + _.padEnd('FooBrowser 88', lengthOfExistingBrowserString)
}

const replaceDurationSeconds = function (str, p1, p2, p3, p4) {
// get the padding for the existing duration
const lengthOfExistingDuration = _.sum([(p2 != null ? p2.length : undefined) || 0, p3.length, p4.length])

return p1 + _.padEnd('X seconds', lengthOfExistingDuration)
}

// duration='1589'
const replaceDurationFromReporter = (str, p1, p2, p3) => {
return p1 + _.padEnd('X', p2.length, 'X') + p3
}

const replaceNodeVersion = (str, p1, p2, p3) => _.padEnd(`${p1}X (/foo/bar/node)`, (p1.length + p2.length + p3.length))

// when swapping out the duration, ensure we pad the
// full length of the duration so it doesn't shift content
const replaceDurationInTables = (str, p1, p2) => {
return _.padStart('XX:XX', p1.length + p2.length)
}

// could be (1 second) or (10 seconds)
// need to account for shortest and longest
const replaceParenTime = (str, p1) => {
return _.padStart('(X second)', p1.length)
}

const replaceScreenshotDims = (str, p1) => _.padStart('(YxX)', p1.length)

const replaceUploadingResults = function (orig, ...rest) {
const adjustedLength = Math.max(rest.length, 2)
const match = rest.slice(0, adjustedLength - 2)
const results = match[1].split('\n').map((res) => res.replace(/\(\d+\/(\d+)\)/g, '(*/$1)'))
.sort()
.join('\n')
const ret = match[0] + results + match[3]

return ret
}

str = str
.replace(browserNameVersionRe, replaceBrowserName)
// numbers in parenths
.replace(/\s\(\d+([ms]|ms)\)/g, '')
// 12:35 -> XX:XX
.replace(/(\s+?)(\d+ms|\d+:\d+:?\d+)/g, replaceDurationInTables)
.replace(/(coffee|js)-\d{3}/g, '$1-456')
// Cypress: 2.1.0 -> Cypress: 1.2.3
.replace(/(Cypress\:\s+)(\d\.\d\.\d)/g, '$11.2.3')
// Node Version: 10.2.3 (Users/jane/node) -> Node Version: X (foo/bar/node)
.replace(/(Node Version\:\s+v)(\d+\.\d+\.\d+)( \(.*\)\s+)/g, replaceNodeVersion)
// 15 seconds -> X second
.replace(/(Duration\:\s+)(\d+\sminutes?,\s+)?(\d+\sseconds?)(\s+)/g, replaceDurationSeconds)
// duration='1589' -> duration='XXXX'
.replace(/(duration\=\')(\d+)(\')/g, replaceDurationFromReporter)
// (15 seconds) -> (XX seconds)
.replace(/(\((\d+ minutes?,\s+)?\d+ seconds?\))/g, replaceParenTime)
.replace(/\r/g, '')
// replaces multiple lines of uploading results (since order not guaranteed)
.replace(/(Uploading Results.*?\n\n)((.*-.*[\s\S\r]){2,}?)(\n\n)/g, replaceUploadingResults)
// fix "Require stacks" for CI
.replace(/^(\- )(\/.*\/packages\/server\/)(.*)$/gm, '$1$3')
// Different browsers have different cross-origin error messages
.replace(crossOriginErrorRe, '[Cross origin error message]')

if (options.sanitizeScreenshotDimensions) {
// screenshot dimensions
str = str.replace(/(\(\d+x\d+\))/g, replaceScreenshotDims)
}

return replaceStackTraceLines(str)
}
Loading

0 comments on commit e39ffd6

Please sign in to comment.