Skip to content

Commit 0a50672

Browse files
committed
Fix for cypress randomstrings
1 parent f6b2197 commit 0a50672

File tree

4 files changed

+20
-18
lines changed

4 files changed

+20
-18
lines changed

test/cypress/integration/api/Settings.spec.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
/// <reference types="Cypress" />
22

3-
const fns = require('../support/functions');
4-
53
describe('Settings endpoints', () => {
64
let token;
7-
let settingName = 'cypressSetting_' + fns.generateRandomString(12);
5+
let settingName;
86

97
before(() => {
108
cy.getToken().then((tok) => {
119
token = tok;
1210
});
11+
cy.randomString(12).then((str) => {
12+
settingName = 'cypressSetting_' + str;
13+
});
1314
});
1415

1516
it('Should be able to create new setting', function() {

test/cypress/integration/api/Users.spec.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
/// <reference types="Cypress" />
22

3-
const fns = require('../support/functions');
4-
53
describe('Users endpoints', () => {
64
let token;
7-
let uniqueEmail = 'jc_' + fns.generateRandomString(10) + '@example.com';
8-
let myUserID = 0;
5+
let uniqueEmail;
6+
let myUserID = 0;
97

108
before(() => {
119
cy.getToken().then((tok) => {
1210
token = tok;
1311
});
12+
cy.randomString(10).then((str) => {
13+
uniqueEmail = 'jc_' + str + '@example.com';
14+
});
1415
});
1516

1617
it('Should be able to get yourself', function() {

test/cypress/support/commands.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@
1111

1212
import 'cypress-wait-until';
1313

14+
Cypress.Commands.add('randomString', (length) => {
15+
var result = '';
16+
var characters = 'ABCDEFGHIJK LMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
17+
var charactersLength = characters.length;
18+
for (var i = 0; i < length; i++) {
19+
result += characters.charAt(Math.floor(Math.random() * charactersLength));
20+
}
21+
return result;
22+
// cy.wrap(result);
23+
});
24+
1425
/**
1526
* Check the swagger schema:
1627
*

test/cypress/support/functions.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)