Skip to content

Commit a558ea7

Browse files
committed
chore(test): Modernize Cypress config
Signed-off-by: Louis Chemineau <louis@chmn.me>
1 parent 216217d commit a558ea7

7 files changed

Lines changed: 515 additions & 322 deletions

File tree

cypress.config.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import {
2-
configureNextcloud,
3-
startNextcloud,
4-
stopNextcloud,
5-
waitOnNextcloud,
6-
} from './cypress/dockerNode'
1+
import { configureNextcloud, startNextcloud, stopNextcloud, waitOnNextcloud } from '@nextcloud/cypress/docker'
72
// eslint-disable-next-line n/no-extraneous-import
83
import { defineConfig } from 'cypress'
94

@@ -48,8 +43,18 @@ export default defineConfig({
4843
// Fix browserslist extend https://github.com/cypress-io/cypress/issues/2983#issuecomment-570616682
4944
on('file:preprocessor', vitePreprocessor({ configFile: false }))
5045

51-
// Enable the snapshot compare plugin
52-
configureVisualRegression(on)
46+
// This allows to store global data (e.g. the name of a snapshot)
47+
// because Cypress.env() and other options are local to the current spec file.
48+
const data = {}
49+
on('task', {
50+
setVariable({ key, value }) {
51+
data[key] = value
52+
return null
53+
},
54+
getVariable({ key }) {
55+
return data[key] ?? null
56+
},
57+
})
5358

5459
// Disable spell checking to prevent rendering differences
5560
on('before:browser:launch', (browser, launchOptions) => {
@@ -76,17 +81,12 @@ export default defineConfig({
7681

7782
// Before the browser launches
7883
// starting Nextcloud testing container
79-
return startNextcloud(process.env.BRANCH)
80-
.then((ip) => {
81-
// Setting container's IP as base Url
82-
config.baseUrl = `http://${ip}/index.php`
83-
return ip
84-
})
85-
.then(waitOnNextcloud)
86-
.then(() => configureNextcloud(process.env.BRANCH))
87-
.then(() => {
88-
return config
89-
})
84+
const ip = await startNextcloud(process.env.BRANCH || 'master')
85+
// Setting container's IP as base Url
86+
config.baseUrl = `http://${ip}/index.php`
87+
await waitOnNextcloud(ip)
88+
await configureNextcloud(['viewer'])
89+
return config
9090
},
9191
},
9292

cypress/docker-compose.yml

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

cypress/dockerNode.ts

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

cypress/tsconfig.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
{
22
"extends": "../tsconfig.json",
3-
"include": ["./**/*.ts"],
3+
"include": [
4+
"../*.ts",
5+
"."
6+
],
47
"compilerOptions": {
8+
"rootDir": "..",
59
"types": [
6-
"@testing-library/cypress",
710
"cypress",
811
"dockerode",
912
"node",
1013
"@testing-library/cypress"
1114
]
1215
}
13-
}
16+
}

0 commit comments

Comments
 (0)