|
| 1 | +// *********************************************************** |
| 2 | +// This example support/component.ts is processed and |
| 3 | +// loaded automatically before your test files. |
| 4 | +// |
| 5 | +// This is a great place to put global configuration and |
| 6 | +// behavior that modifies Cypress. |
| 7 | +// |
| 8 | +// You can change the location of this file or turn off |
| 9 | +// automatically serving support files with the |
| 10 | +// 'supportFile' configuration option. |
| 11 | +// |
| 12 | +// You can read more here: |
| 13 | +// https://on.cypress.io/configuration |
| 14 | +// *********************************************************** |
| 15 | + |
| 16 | +// Import commands.js using ES2015 syntax: |
| 17 | +import './commands'; |
| 18 | + |
| 19 | +// Alternatively you can use CommonJS syntax: |
| 20 | +// require('./commands') |
| 21 | + |
| 22 | +import { mount } from 'cypress/vue'; |
| 23 | + |
| 24 | +// Augment the Cypress namespace to include type definitions for |
| 25 | +// your custom command. |
| 26 | +// Alternatively, can be defined in cypress/support/component.d.ts |
| 27 | +// with a <reference path="./component" /> at the top of your spec. |
| 28 | +declare global { |
| 29 | + namespace Cypress { |
| 30 | + interface Chainable { |
| 31 | + mount: typeof mount; |
| 32 | + } |
| 33 | + } |
| 34 | +} |
| 35 | + |
| 36 | +Cypress.Commands.add('mount', mount); |
| 37 | + |
| 38 | +export function getInt(max: number) { |
| 39 | + return Math.floor(Math.random() * max); |
| 40 | +} |
| 41 | + |
| 42 | +export function getRandomSequence(maxLength: number) { |
| 43 | + const sequence: number[] = []; |
| 44 | + |
| 45 | + let newLength = maxLength; |
| 46 | + let prev: number | undefined = undefined; |
| 47 | + |
| 48 | + for (let i = 0; i < newLength; i++) { |
| 49 | + const next = getInt(maxLength); |
| 50 | + |
| 51 | + if (typeof prev === 'undefined') { |
| 52 | + prev = next; |
| 53 | + continue; |
| 54 | + } |
| 55 | + if (prev === next) { |
| 56 | + newLength++; |
| 57 | + continue; |
| 58 | + } |
| 59 | + |
| 60 | + prev = next; |
| 61 | + sequence.push(next); |
| 62 | + } |
| 63 | + |
| 64 | + return sequence; |
| 65 | +} |
0 commit comments