Skip to content

Commit

Permalink
cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
limonte committed Dec 19, 2019
1 parent 3aaade7 commit 89d5b12
Show file tree
Hide file tree
Showing 10 changed files with 1,901 additions and 1,066 deletions.
50 changes: 9 additions & 41 deletions .github/workflows/ci.yml
Expand Up @@ -17,56 +17,24 @@ jobs:
- name: Install npm dependencies
run: yarn install

- name: Build
run: yarn build

- name: Run linters
run: yarn lint
- name: Instrument
run: yarn nyc:instrument

- name: Run tests
run: yarn test

- name: Check TypeScript
run: |
tsc --lib dom,es6 --noEmit test/ts/simple-usage.ts sweetalert2.d.ts
tsc --lib dom,es6 --noEmit test/ts/dist-sweetalert2.ts sweetalert2.d.ts
tsc --lib dom,es6 --noEmit test/ts/src-sweetalert2.ts sweetalert2.d.ts
- name: Run automated release process with semantic-release
if: github.event_name == 'push'
uses: cycjimmy/semantic-release-action@v2
with:
extra_plugins: |
@semantic-release/changelog
@semantic-release/git
@semantic-release/exec
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: yarn cypress:run

- name: Report coverage to coveralls.io
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

# TODO: remove after https://github.com/bundlewatch/bundlewatch/pull/66 is merged and released
# https://stackoverflow.com/a/58035262
- name: Extract the branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch

- name: Report bundlezise to bundlewatch.io
- name: Report coverage to codeclimate.com
uses: paambaati/codeclimate-action@v2.3.0
env:
BUNDLEWATCH_GITHUB_TOKEN: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
# TODO: remove after https://github.com/bundlewatch/bundlewatch/pull/66 is merged and released
CI_REPO_OWNER: "sweetalert2"
CI_REPO_NAME: "sweetalert2"
CI_COMMIT_SHA: ${{ github.sha }}
CI_BRANCH: ${{ steps.extract_branch.outputs.branch }}
run: |
yarn add --dev bundlewatch
./node_modules/.bin/bundlewatch
CC_TEST_REPORTER_ID: efba756cbfb334e9e5aebbc8df3267419072918409c8fc42a4c3cfdb4ee6e693
with:
coverageCommand: echo "already performed"
debug: true

skip:
if: "contains(github.event.commits[0].message, '[skip ci]')"
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
@@ -1,6 +1,9 @@
node_modules
package-lock.json
dist
cypress/videos
instrumented
coverage
.nyc_output
.idea
.vscode
1 change: 1 addition & 0 deletions cypress.json
@@ -0,0 +1 @@
{}
12 changes: 12 additions & 0 deletions cypress/.eslintrc.js
@@ -0,0 +1,12 @@
module.exports = {
plugins: [
'cypress'
],
env: {
'cypress/globals': true
},
rules: {
'no-unused-expressions': 0,
'import/extensions': 0,
}
}
8 changes: 8 additions & 0 deletions cypress/integration/examples/sample.spec.js
@@ -0,0 +1,8 @@
import Swal from '../../../instrumented/sweetalert2'

describe('My First Test', function () {
it('version is correct semver', () => {
Swal.fire()
expect(!!Swal.version.match(/\d+\.\d+\.\d+/)).to.be.true
})
})
16 changes: 16 additions & 0 deletions cypress/plugins/index.js
@@ -0,0 +1,16 @@
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

module.exports = (on, config) => {
on('task', require('@cypress/code-coverage/task'))
}
25 changes: 25 additions & 0 deletions cypress/support/commands.js
@@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
19 changes: 19 additions & 0 deletions cypress/support/index.js
@@ -0,0 +1,19 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

import '@cypress/code-coverage/support'
20 changes: 8 additions & 12 deletions package.json
Expand Up @@ -12,14 +12,17 @@
"@babel/core": "^7.2.2",
"@babel/plugin-transform-object-assign": "^7.2.0",
"@babel/preset-env": "^7.3.1",
"@cypress/code-coverage": "^1.10.4",
"@sweetalert2/eslint-config": "^1.0.0",
"@sweetalert2/execute": "^1.0.0",
"@sweetalert2/stylelint-config": "^1.1.5",
"babel-loader": "^8.0.4",
"babel-plugin-array-includes": "^2.0.3",
"browser-sync": "^2.26.3",
"custom-event-polyfill": "^1.0.6",
"cypress": "^3.8.0",
"eslint": "^6.0.0",
"eslint-plugin-cypress": "^2.8.1",
"gulp": "^4.0.0",
"gulp-autoprefixer": "^7.0.0",
"gulp-clean-css": "^4.0.0",
Expand All @@ -29,20 +32,11 @@
"gulp-rename": "^1.2.2",
"gulp-rollup": "^2.16.2",
"gulp-uglify": "^3.0.0",
"istanbul-lib-coverage": "^2.0.5",
"jquery": "^3.3.1",
"karma": "^4.0.0",
"karma-chrome-launcher": "^3.0.0",
"karma-coverage": "^2.0.0",
"karma-firefox-launcher": "^1.1.0",
"karma-ie-launcher": "^1.0.0",
"karma-qunit": "^4.0.0",
"karma-sauce-launcher": "^2.0.2",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "^0.0.32",
"karma-webpack": "^4.0.0",
"merge2": "^1.2.3",
"nyc": "^14.1.1",
"promise-polyfill": "^8.1.0",
"qunit": "^2.8.0",
"replace-in-file": "^5.0.2",
"rollup": "^1.1.2",
"rollup-plugin-babel": "^4.3.2",
Expand Down Expand Up @@ -89,7 +83,9 @@
"start": "gulp develop --continue-on-error --skip-minification --skip-standalone",
"lint": "stylelint src && eslint src test tools *.js *.ts",
"build": "gulp build",
"test": "karma start karma.conf.js --single-run"
"cypress:open": "cypress open",
"cypress:run": "cypress run",
"nyc:instrument": "nyc instrument --compact=false src instrumented"
},
"funding": {
"url": "https://sweetalert2.github.io/#donations"
Expand Down

0 comments on commit 89d5b12

Please sign in to comment.