-
Notifications
You must be signed in to change notification settings - Fork 0
/
cypress.config.ts
78 lines (68 loc) · 3.15 KB
/
cypress.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/// <reference path="./node_modules/cypress/types/cypress.d.ts" />
import { defineConfig } from "cypress";
import { cypressCommonConfig } from "./configs/cypress.common.config";
import { jsonpath, readXlsxFile, validateSchema, xmlToJs } from "./configs/cypress.taks";
import { collectFailingTests } from "cypress-plugin-last-failed";
import { config } from "dotenv";
// const { allureCypress } = require("allure-cypress/reporter");
config({ path: './.env' });
// @type {Cypress.Option}
export default defineConfig({
e2e: {
async setupNodeEvents(
_on: Cypress.PluginEvents,
config: Cypress.PluginConfigOptions
): Promise<Cypress.PluginConfigOptions> {
const on = require('cypress-on-fix')(_on)
on("before:browser:launch", (browser, launchOptions) => {
if (browser.family === 'chromium' && browser.name !== 'electron') {
launchOptions.args.push("--incognito");
return launchOptions;
}
if (browser.name === 'electron') {
launchOptions.preferences.incognito = true;
return launchOptions;
}
});
/*
npx cypress run --env grep="auth user" - # run only the tests with "auth user" in the title
npx cypress run --env grep="hello; auth user" - # run tests with "hello" or "auth user" in their titles by separating them with ";" character
npx cypress run --env grepTags=@fast - # run tests tagged @fast
npx cypress run --env grep=login,grepTags=smoke - # that have "login" in their titles - # run only the tests tagged "smoke"
npx cypress run --env grep=user,grepFilterSpecs=true - # only run the specs that have any tests with "user" in their titles
npx cypress run --env grepTags=@smoke,grepFilterSpecs=true - # only run the specs that have any tests tagged "@smoke"
npx cypress run --env grepUntagged=true - # run only tests that do not have any tags and are not inside suites that have any tags
*/
// 1. cypress tag
// You can filter tests to run using part of their title via 'grep', and via explicit tags via 'grepTags' Cypress environment variables.
require('@cypress/grep/src/plugin')(config);
// 2. cypress mochaawesome reporter
require('cypress-mochawesome-reporter/plugin')(on);
// 3. allure reporter
// allureCypress(on, {
// resultsDir: "./reports/allure-results",
// environmentInfo: { "author": "Krishna" }
// // videoOnFailOnly: true
// });
// 4. .env Plugin
// config = dotenvPlugin(config, { path: './.env' });
// 5. Collect and run only failed tests
collectFailingTests(on, config);
// @ts-ignore
on("task", { validateSchema });
// @ts-ignore
on('task', { jsonpath });
on("task", { readXlsxFile });
on("task", { xmlToJs });
// conf = await cloudPlugin(on, config);
return config;
},
specPattern: "cypress/e2e/**/*.spec.*{ts,js}",
supportFolder: "cypress/support",
// baseUrl: "https://the-internet.herokuapp.com/",
baseUrl: "https://www.phptravels.net/",
excludeSpecPattern: ["*.feature", "*.json", "*.md", "*.html"],
testIsolation: true
},
...cypressCommonConfig
});