https://github.com/nextcloud-libraries/nextcloud-cypress
Nextcloud cypress commands, utils and selectors library https://npmjs.org/@nextcloud/cypress
https://github.com/nextcloud-libraries/nextcloud-cypress
javascript-library
Last synced: 4 months ago
JSON representation
Nextcloud cypress commands, utils and selectors library https://npmjs.org/@nextcloud/cypress
- Host: GitHub
- URL: https://github.com/nextcloud-libraries/nextcloud-cypress
- Owner: nextcloud-libraries
- License: agpl-3.0
- Created: 2022-06-23T15:30:03.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-29T21:12:33.000Z (9 months ago)
- Last Synced: 2024-10-29T23:37:12.900Z (9 months ago)
- Topics: javascript-library
- Language: TypeScript
- Homepage: https://nextcloud-libraries.github.io/nextcloud-cypress/
- Size: 11.3 MB
- Stars: 1
- Watchers: 5
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Authors: AUTHORS.md
Awesome Lists containing this project
README
# \@nextcloud/cypress
[](https://api.reuse.software/info/github.com/nextcloud-libraries/nextcloud-cypress) [](https://www.npmjs.com/package/@nextcloud/cypress) 
Nextcloud cypress helpers for Nextcloud apps and libraries
## New package available
`@nextcloud/e2e-test-server` is a more generic version of `@nextcloud/cypress`
that will work nicely with both cypress and playwright.It will eventually superseed `@nextcloud/cypress`.
When starting a new project we recommend using `@nextcloud/e2e-test-server`.## Commands
You can import individual commands or all at once
You can find [the list of all available commands here](https://nextcloud.github.io/nextcloud-cypress/modules/commands.html)```js
// cypress/support/commands.js
import { addCommands } from '@nextcloud/cypress'addCommands()
``````js
// cypress/support/commands.js
import { getNc } from '@nextcloud/cypress/commands'Cypress.Commands.add('getNc', getNc)
```## Selectors
You can find [the list of all available selectors here](https://nextcloud.github.io/nextcloud-cypress/modules/selectors.html)
```js
import { UploadPicker as UploadPickerComponent} from '../../dist/index.js'
import { UploadPicker, UploadPickerInput } from '@nextcloud/cypress/selectors'describe('UploadPicker rendering', () => {
it('Renders default UploadPicker', () => {
cy.mount(UploadPickerComponent)
cy.getNc(UploadPicker).should('exist')
.should('have.class', 'upload-picker')
cy.getNc(UploadPickerInput).should('exist')
})
})
```## Starting Nextcloud Docker container
It is possible to automatically start a docker container providing a Nextcloud instance for testing.
Therefor adjust your `cypress.config.ts` (or `.js`):```js
import { configureNextcloud, startNextcloud, stopNextcloud, waitOnNextcloud } from '@nextcloud/cypress/docker'export default defineConfig({
// ...
e2e: {
// other configurationsetupNodeEvents(on, config) {
// Remove container after run
on('after:run', () => {
stopNextcloud()
})// starting Nextcloud testing container with specified server branch
return startNextcloud(process.env.BRANCH)
.then((ip) => {
// Setting container's IP as base Url
config.baseUrl = `http://${ip}/index.php`
return ip
})
.then(waitOnNextcloud)
// configure Nextcloud, also install and enable the `viewer` app
.then(() => configureNextcloud(['viewer']))
.then(() => {
return config
})
},
},
})
```