Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Dec 15, 2022
0 parents commit 9a2c870
Show file tree
Hide file tree
Showing 74 changed files with 2,334 additions and 0 deletions.
603 changes: 603 additions & 0 deletions README.md

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const { defineConfig } = require('cypress')

module.exports = defineConfig({
e2e: {
defaultCommandTimeout: 1000,
setupNodeEvents (on, config) {
require('./src/plugin')(config)

return config
},
specPattern: '**/spec.js',
},
fixturesFolder: false,
video: false,
})
17 changes: 17 additions & 0 deletions cypress/e2e/before-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
describe('Runs before and beforeEach when first test is skipped', () => {
let count = 0

before(() => {
count++
})

beforeEach(() => {
count++
})

it('A', { tags: ['@core'] }, () => {})

it('B', { tags: ['@core', '@staging'] }, () => {
expect(count).to.equal(2)
})
})
9 changes: 9 additions & 0 deletions cypress/e2e/burn-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// <reference types="cypress" />

// if we specify just the burn parameter
// then this test will be repeated N times
describe('burning a test N times', () => {
it('repeats', () => {})

it('second test', () => {})
})
7 changes: 7 additions & 0 deletions cypress/e2e/config-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// @ts-check
/// <reference types="cypress" />
describe('tests that use config object', () => {
it('still works @config', { baseUrl: 'http://localhost:8000' }, () => {
expect(Cypress.config('baseUrl')).to.equal('http://localhost:8000')
})
})
16 changes: 16 additions & 0 deletions cypress/e2e/config-tags-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// @ts-check
/// <reference path="../../src/index.d.ts" />
describe('tags in the config object', () => {
it('works as an array', { tags: ['config', 'some-other-tag'] }, () => {
expect(true).to.be.true
})

it('works as a string', { tags: 'config' }, () => {
expect(true).to.be.true
})

it('does not use tags', () => {
// so it fails
expect(true).to.be.false
})
})
23 changes: 23 additions & 0 deletions cypress/e2e/describe-tags-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/// <reference path="../../src/index.d.ts" />

// @ts-check

describe('block with no tags', () => {
it('inside describe 1', () => {})

it('inside describe 2', () => {})
})

describe('block with tag smoke', { tags: '@smoke' }, () => {
it('inside describe 3', () => {})

it('inside describe 4', () => {})
})

describe('block without any tags', () => {
// note the parent suite has no tags
// so this test should run when using --env grepTags=@smoke
it('test with tag smoke', { tags: '@smoke' }, () => {})
})

it('is a test outside any suites', () => {})
11 changes: 11 additions & 0 deletions cypress/e2e/each-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// <reference types="cypress" />

// https://github.com/bahmutov/cypress-each
import 'cypress-each'

describe('tests that use .each work', () => {
// creating tests dynamically works with "cypress-grep"
it.each([1, 2, 3])('test for %d', (x) => {
expect(x).to.be.oneOf([1, 2, 3])
})
})
7 changes: 7 additions & 0 deletions cypress/e2e/inherits-tag-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/// <reference types="cypress" />

describe('Screen A', { tags: ['@sanity', '@screen-a'] }, () => {
it('loads', { tags: ['@screen-b'] }, () => {
// do something that eventually sends the page to screen b.
})
})
10 changes: 10 additions & 0 deletions cypress/e2e/multiple-registrations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/// <reference types="cypress" />

// register the plugin multiple times
// to simulate including from support and spec files
// https://github.com/cypress-io/cypress-grep/issues/59
require('../../src/support')()
require('../../src/support')()
require('../../src/support')()

it('hello world', () => {})
18 changes: 18 additions & 0 deletions cypress/e2e/nested-describe-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/// <reference path="../../src/index.d.ts" />

// @ts-check
describe('grand', () => {
context('outer', { tags: '@smoke' }, () => {
describe('inner', () => {
it('runs', () => {})
})
})
})

describe('top', { tags: '@smoke' }, () => {
describe('middle', () => {
context('bottom', { tags: ['@integration', '@fast'] }, () => {
it('runs too', () => {});
})
})
})
10 changes: 10 additions & 0 deletions cypress/e2e/omit-and-skip-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/// <reference path="../../src/index.d.ts" />

// @ts-check
describe('Page', () => {
describe('List', { tags: ['@us1'] }, () => {
it.skip('first test', () => {})
it('second test', () => {})
it('third test', () => {})
})
})
9 changes: 9 additions & 0 deletions cypress/e2e/skip-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// <reference types="cypress" />
describe('tests that use .skip', () => {
// use a template literal
it(`works`, () => {})

it.skip('is pending', () => {})

it.skip('is pending again', () => {})
})
11 changes: 11 additions & 0 deletions cypress/e2e/spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// <reference types="cypress" />

it('hello world', () => {})

it('works', () => {})

it('works 2 @tag1', { tags: '@tag1' }, () => {})

it('works 2 @tag1 @tag2', { tags: ['@tag1', '@tag2'] }, () => {})

it('works @tag2', { tags: '@tag2' }, () => {})
13 changes: 13 additions & 0 deletions cypress/e2e/specify-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/// <reference types="cypress" />

// specify is the same as it()

specify('hello world', () => {})

specify('works', () => {})

specify('works 2 @tag1', { tags: '@tag1' }, () => {})

specify('works 2 @tag1 @tag2', { tags: ['@tag1', '@tag2'] }, () => {})

specify('works @tag2', { tags: '@tag2' }, () => {})
5 changes: 5 additions & 0 deletions cypress/e2e/tags/test1.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="cypress" />

it('Test 1', { tags: ['smoke', 'regression'] }, () => {
expect(true).to.be.true
})
5 changes: 5 additions & 0 deletions cypress/e2e/tags/test2.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="cypress" />

it('Test 2', { tags: ['high', 'smoke'] }, () => {
expect(true).to.be.true
})
5 changes: 5 additions & 0 deletions cypress/e2e/tags/test3.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="cypress" />

it('Test 3', { tags: ['smoke'] }, () => {
expect(true).to.be.true
})
11 changes: 11 additions & 0 deletions cypress/e2e/this-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// <reference types="cypress" />
describe('this context', () => {
beforeEach(() => {
cy.wrap(42).as('life')
})

it('preserves the test context', function () {
expect(this).to.be.an('object')
expect(this.life).to.equal(42)
})
})
29 changes: 29 additions & 0 deletions cypress/e2e/ts-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
describe('TypeScript spec', () => {
it('works', () => {
type Person = {
name: string
}

const person: Person = {
name: 'Joe',
}

cy.wrap(person).should('have.property', 'name', 'Joe')
})

it('loads', () => {
const n: number = 1
cy.wrap(n).should('eq', 1)
})

it('loads interfaces', () => {
interface Person {
name: string
}

const p: Person = {
name: 'Joe',
}
cy.wrap(p).should('have.property', 'name', 'Joe')
})
})
Loading

0 comments on commit 9a2c870

Please sign in to comment.