diff --git a/.eslintignore b/.eslintignore index 3144cd93..03d535f7 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,4 @@ -generators/app/templates/specs/integration/landing_spec.js +generators/app/templates/specs/e2e/landing.cy.js generators/app/templates/specs/mocha/rest_spec.js generators/app/templates/specs/xqs/xqSuite.js diff --git a/README.md b/README.md index 62fa3b66..4d44fa98 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ First, install [Yeoman](http://yeoman.io) and generator-exist using [npm](https: To install a pre-release version: ```bash -npm i -g yo +npm i -g yo@4 npm i -g git://github.com/eXist-db/generator-exist.git ``` @@ -26,7 +26,7 @@ npm i -g git://github.com/eXist-db/generator-exist.git To install a version published to npm: ```bash -npm i -g yo +npm i -g yo@4 npm i -g @existdb/generator-exist ``` @@ -35,7 +35,7 @@ npm i -g @existdb/generator-exist Alternatively, if you have cloned this repo from GitHub. You can symlink your local clone into your global node environment. This is particularly useful during development. From inside the folder with the cloned repo: ```bash -npm install -g yo +npm install -g yo@4 npm i npm link ``` @@ -105,7 +105,7 @@ Since if would be impractical to go through all possible combinations of option ├── build.xml ├── collection.xconf ├── controller.xq -├── cypress.json +├── cypress.config.js ├── error-page.html ├── expath-pkg.xml ├── icon.png @@ -154,15 +154,13 @@ Since if would be impractical to go through all possible combinations of option ├── cypress │   ├── fixtures │   │   └── example.json - │   ├── integration - │   │   ├── landing_spec.js + │   ├── e2e + │   │   ├── landing.cy.js │   │   ├── login-fail_spec.js │   │   └── login-ok_spec.js - │   ├── plugins - │   │   └── index.js │   └── support │   ├── commands.js - │   └── index.js + │   └── e2e.js ├── mocha │   ├── app_spec.js │   └── rest_spec.js @@ -183,7 +181,7 @@ Since if would be impractical to go through all possible combinations of option ├── build.xml ├── collection.xconf ├── controller.xq -├── cypress.json +├── cypress.config.js ├── error-page.html ├── expath-pkg.xml ├── icon.png @@ -211,13 +209,11 @@ Since if would be impractical to go through all possible combinations of option ├── cypress │   ├── fixtures │   │   └── example.json - │   ├── integration - │   │   └── landing_spec.js - │   ├── plugins - │   │   └── index.js + │   ├── e2e + │   │   └── landing.cy.js │   └── support │   ├── commands.js - │   └── index.js + │   └── e2e.js ├── mocha │   ├── app_spec.js │   └── rest_spec.js @@ -235,7 +231,7 @@ Since if would be impractical to go through all possible combinations of option │   ├── empty_demo-1.0.0-dev.xar │   └── empty_demo-1.0.0.xar ├── build.xml -├── cypress.json +├── cypress.config.js ├── expath-pkg.xml ├── icon.png ├── node_modules @@ -250,13 +246,11 @@ Since if would be impractical to go through all possible combinations of option ├── cypress │   ├── fixtures │   │   └── example.json - │   ├── integration - │   │   └── landing_spec.js - │   ├── plugins - │   │   └── index.js + │   ├── e2e + │   │   └── landing.cy.js │   └── support │   ├── commands.js - │   └── index.js + │   └── e2e.js ├── mocha │   ├── app_spec.js │   └── rest_spec.js diff --git a/generators/app/index.js b/generators/app/index.js index 6ad63b09..02723334 100644 --- a/generators/app/index.js +++ b/generators/app/index.js @@ -391,7 +391,15 @@ module.exports = class extends Generator { }, repository: '' } - this.npmInstall(['chai', 'chai-xml', 'fs-extra', 'mocha', 'supertest', 'xmldoc', 'yeoman-assert'], { 'save-dev': true }) + this.env.options.nodePackageManager = 'npm' + // see https://github.com/yeoman/generator/issues/1294 + this.npmInstall(['chai'], { 'save-dev': true }) + this.npmInstall(['chai-xml'], { 'save-dev': true }) + this.npmInstall(['fs-extra'], { 'save-dev': true }) + this.npmInstall(['mocha'], { 'save-dev': true }) + this.npmInstall(['supertest'], { 'save-dev': true }) + this.npmInstall(['xmldoc'], { 'save-dev': true }) + this.npmInstall(['yeoman-assert'], { 'save-dev': true }) // Applies to all (without prompts) // TODO #56 html -> xhtml @@ -498,8 +506,8 @@ module.exports = class extends Generator { ) this.fs.copy( - this.templatePath('specs/cypress.json'), - this.destinationPath('cypress.json') + this.templatePath('specs/cypress.config.js'), + this.destinationPath('cypress.config.js') ) this.fs.copy( @@ -513,8 +521,8 @@ module.exports = class extends Generator { ) this.fs.copyTpl( - this.templatePath('specs/integration/landing_spec.js'), - this.destinationPath('test/cypress/integration/landing_spec.js'), { + this.templatePath('specs/e2e/landing.cy.js'), + this.destinationPath('test/cypress/e2e/landing.cy.js'), { apptype: this.props.apptype[0], short: this.props.short, defcoll: this.props.defcoll, @@ -681,8 +689,8 @@ module.exports = class extends Generator { this.destinationPath('templates/') ) this.fs.copyTpl( - this.templatePath('specs/integration/login-*_spec.js'), - this.destinationPath('test/cypress/integration/'), { + this.templatePath('specs/e2e/login-*.cy.js'), + this.destinationPath('test/cypress/e2e/'), { defcoll: this.props.defcoll, short: this.props.short }) diff --git a/generators/app/templates/specs/cypress.config.js b/generators/app/templates/specs/cypress.config.js new file mode 100644 index 00000000..786c69d9 --- /dev/null +++ b/generators/app/templates/specs/cypress.config.js @@ -0,0 +1,16 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + screenshotsFolder: 'reports/screenshots', + videosFolder: 'reports/videos', + fixturesFolder: 'test/cypress/fixtures', + e2e: { + setupNodeEvents (on, config) { + // implement node event listeners here + }, + baseUrl: 'http://localhost:8080', + includeShadowDom: true, + specPattern: 'test/cypress/e2e/**/*.cy.{js,jsx,ts,tsx}', + supportFile: 'test/cypress/support/e2e.js' + } +}) diff --git a/generators/app/templates/specs/cypress.json b/generators/app/templates/specs/cypress.json deleted file mode 100644 index 6701e73c..00000000 --- a/generators/app/templates/specs/cypress.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "baseUrl": "http://localhost:8080", - "screenshotsFolder": "reports/screenshots", - "videosFolder": "reports/videos", - "fixturesFolder": "test/cypress/fixtures", - "integrationFolder": "test/cypress/integration", - "pluginsFile": "test/cypress/plugins/index.js", - "supportFile": "test/cypress/support/index.js" -} diff --git a/generators/app/templates/specs/cypress/plugins/index.js b/generators/app/templates/specs/cypress/plugins/index.js deleted file mode 100644 index fd170fba..00000000 --- a/generators/app/templates/specs/cypress/plugins/index.js +++ /dev/null @@ -1,17 +0,0 @@ -// *********************************************************** -// This example plugins/index.js can be used to load plugins -// -// You can change the location of this file or turn off loading -// the plugins file with the 'pluginsFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/plugins-guide -// *********************************************************** - -// This function is called when a project is opened or re-opened (e.g. due to -// the project's config changing) - -module.exports = (on, config) => { - // `on` is used to hook into various events Cypress emits - // `config` is the resolved Cypress config -} diff --git a/generators/app/templates/specs/cypress/support/commands.js b/generators/app/templates/specs/cypress/support/commands.js index c1f5a772..119ab03f 100644 --- a/generators/app/templates/specs/cypress/support/commands.js +++ b/generators/app/templates/specs/cypress/support/commands.js @@ -10,16 +10,16 @@ // // // -- This is a parent command -- -// Cypress.Commands.add("login", (email, password) => { ... }) +// Cypress.Commands.add('login', (email, password) => { ... }) // // // -- This is a child command -- -// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) +// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) // // // -- This is a dual command -- -// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) +// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) // // -// -- This is will overwrite an existing command -- -// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) +// -- This will overwrite an existing command -- +// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) diff --git a/generators/app/templates/specs/cypress/support/index.js b/generators/app/templates/specs/cypress/support/e2e.js similarity index 92% rename from generators/app/templates/specs/cypress/support/index.js rename to generators/app/templates/specs/cypress/support/e2e.js index d68db96d..d1dd1353 100644 --- a/generators/app/templates/specs/cypress/support/index.js +++ b/generators/app/templates/specs/cypress/support/e2e.js @@ -1,5 +1,5 @@ // *********************************************************** -// This example support/index.js is processed and +// This example support/e2e.js is processed and // loaded automatically before your test files. // // This is a great place to put global configuration and diff --git a/generators/app/templates/specs/integration/landing_spec.js b/generators/app/templates/specs/e2e/landing.cy.js similarity index 100% rename from generators/app/templates/specs/integration/landing_spec.js rename to generators/app/templates/specs/e2e/landing.cy.js diff --git a/generators/app/templates/specs/integration/login-fail_spec.js b/generators/app/templates/specs/e2e/login-fail.cy.js similarity index 100% rename from generators/app/templates/specs/integration/login-fail_spec.js rename to generators/app/templates/specs/e2e/login-fail.cy.js diff --git a/generators/app/templates/specs/integration/login-ok_spec.js b/generators/app/templates/specs/e2e/login-ok.cy.js similarity index 100% rename from generators/app/templates/specs/integration/login-ok_spec.js rename to generators/app/templates/specs/e2e/login-ok.cy.js diff --git a/test/generated-pkg/app-eXide-plain.js b/test/generated-pkg/app-eXide-plain.js index eeb2988f..f1c821cb 100644 --- a/test/generated-pkg/app-eXide-plain.js +++ b/test/generated-pkg/app-eXide-plain.js @@ -26,7 +26,7 @@ describe('eXide plain app', function () { admin: 'admin', adminpw: 'pw123' }) - assert.noFile(['resources/images/bold.gif', 'pre-install.xq', 'test/cypress/integration/secure_spec.js', '.travis.yml', 'resources/css/exist-2.2.css']) + assert.noFile(['resources/images/bold.gif', 'pre-install.xq', 'test/cypress/e2e/secure.cy.js', '.travis.yml', 'resources/css/exist-2.2.css']) }) describe('plain package has', function () { diff --git a/test/generated-pkg/app-empty.js b/test/generated-pkg/app-empty.js index 435121b3..ea2e6c94 100644 --- a/test/generated-pkg/app-empty.js +++ b/test/generated-pkg/app-empty.js @@ -19,7 +19,7 @@ describe('empty package', function () { github: false, atom: false }) - assert.noFile(['modules/app.xqm', 'templates/page.html', 'test/cypress/integration/login-ok_spec.js', 'index.html']) + assert.noFile(['modules/app.xqm', 'templates/page.html', 'test/cypress/e2e/login-ok.cy.js', 'index.html']) }) describe('empty has', function () { diff --git a/test/generated-pkg/app-mysec.js b/test/generated-pkg/app-mysec.js index f07c85a4..fc8bac9e 100644 --- a/test/generated-pkg/app-mysec.js +++ b/test/generated-pkg/app-mysec.js @@ -26,7 +26,7 @@ describe('eXide style …', function () { describe('secure exist design has …', function () { it('default files and restricted area', function (done) { - assert.file(['admin/controller.xq', 'admin/index.html', 'templates/login-panel.html', 'pre-install.xq', 'test/cypress/integration/login-ok_spec.js']) + assert.file(['admin/controller.xq', 'admin/index.html', 'templates/login-panel.html', 'pre-install.xq', 'test/cypress/e2e/login-ok.cy.js']) done() }) diff --git a/test/util/meta-test.js b/test/util/meta-test.js index e517e114..f7338472 100644 --- a/test/util/meta-test.js +++ b/test/util/meta-test.js @@ -7,7 +7,7 @@ exports.metaTest = function () { }) it('integration-tests', function (done) { - assert.file(['cypress.json', 'test/cypress/integration/landing_spec.js', 'reports/videos/.gitkeep']) + assert.file(['cypress.config.js', 'test/cypress/e2e/landing.cy.js', 'reports/videos/.gitkeep']) done() }) }