Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/curttimson/hugo-theme-massively.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCurtis Timson <curt@live.co.uk>2022-03-31 14:15:31 +0300
committerGitHub <noreply@github.com>2022-03-31 14:15:31 +0300
commit29095f53dc3a94a6b7ea4dca77bfd01e7e1243fb (patch)
tree62d6cfda2fddce22fcdf48e39b4796637f7ced0a /cypress
parentfc9a5d2b5b8ff6b92eb14846ee840940b850e5e7 (diff)
✅ Cypress e2e tests (#103)
* ✅ Cypress e2e tests * update posts * add post test * use base * revert publish change * add e2e workflow
Diffstat (limited to 'cypress')
-rw-r--r--cypress/fixtures/example.json5
-rw-r--r--cypress/integration/home.test.ts11
-rw-r--r--cypress/integration/post.test.ts20
-rw-r--r--cypress/plugins/index.js22
-rw-r--r--cypress/support/commands.js25
-rw-r--r--cypress/support/index.js20
-rw-r--r--cypress/tsconfig.json16
7 files changed, 119 insertions, 0 deletions
diff --git a/cypress/fixtures/example.json b/cypress/fixtures/example.json
new file mode 100644
index 0000000..02e4254
--- /dev/null
+++ b/cypress/fixtures/example.json
@@ -0,0 +1,5 @@
+{
+ "name": "Using fixtures to represent data",
+ "email": "hello@cypress.io",
+ "body": "Fixtures are a great way to mock data for responses to routes"
+}
diff --git a/cypress/integration/home.test.ts b/cypress/integration/home.test.ts
new file mode 100644
index 0000000..ab3a1d7
--- /dev/null
+++ b/cypress/integration/home.test.ts
@@ -0,0 +1,11 @@
+describe('Home', () => {
+ before(() => {
+ cy.visit('http://localhost:1313/');
+ });
+
+ it('displays title', () => {
+ cy.get('h1')
+ .contains('This is Massively');
+ });
+
+});
diff --git a/cypress/integration/post.test.ts b/cypress/integration/post.test.ts
new file mode 100644
index 0000000..afa27ae
--- /dev/null
+++ b/cypress/integration/post.test.ts
@@ -0,0 +1,20 @@
+const post = {
+ date: 'March 29, 2022',
+ slug: 'lorem-ipsum',
+ title: 'Lorem Ipsum',
+}
+
+describe('Post', () => {
+ before(() => {
+ cy.visit(`http://localhost:1313/post/${post.slug}`);
+ });
+
+ it('displays date', () => {
+ cy.get('.date').contains(post.date);
+ })
+
+ it('displays title', () => {
+ cy.get('h1')
+ .contains(post.title);
+ });
+});
diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js
new file mode 100644
index 0000000..59b2bab
--- /dev/null
+++ b/cypress/plugins/index.js
@@ -0,0 +1,22 @@
+/// <reference types="cypress" />
+// ***********************************************************
+// 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)
+
+/**
+ * @type {Cypress.PluginConfig}
+ */
+// eslint-disable-next-line no-unused-vars
+module.exports = (on, config) => {
+ // `on` is used to hook into various events Cypress emits
+ // `config` is the resolved Cypress config
+}
diff --git a/cypress/support/commands.js b/cypress/support/commands.js
new file mode 100644
index 0000000..119ab03
--- /dev/null
+++ b/cypress/support/commands.js
@@ -0,0 +1,25 @@
+// ***********************************************
+// This example commands.js shows you how to
+// create various custom commands and overwrite
+// existing commands.
+//
+// For more comprehensive examples of custom
+// commands please read more here:
+// https://on.cypress.io/custom-commands
+// ***********************************************
+//
+//
+// -- This is a parent command --
+// Cypress.Commands.add('login', (email, password) => { ... })
+//
+//
+// -- This is a child command --
+// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
+//
+//
+// -- This is a dual command --
+// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
+//
+//
+// -- This will overwrite an existing command --
+// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
diff --git a/cypress/support/index.js b/cypress/support/index.js
new file mode 100644
index 0000000..d68db96
--- /dev/null
+++ b/cypress/support/index.js
@@ -0,0 +1,20 @@
+// ***********************************************************
+// This example support/index.js is processed and
+// loaded automatically before your test files.
+//
+// This is a great place to put global configuration and
+// behavior that modifies Cypress.
+//
+// You can change the location of this file or turn off
+// automatically serving support files with the
+// 'supportFile' configuration option.
+//
+// You can read more here:
+// https://on.cypress.io/configuration
+// ***********************************************************
+
+// Import commands.js using ES2015 syntax:
+import './commands'
+
+// Alternatively you can use CommonJS syntax:
+// require('./commands')
diff --git a/cypress/tsconfig.json b/cypress/tsconfig.json
new file mode 100644
index 0000000..b4e8a38
--- /dev/null
+++ b/cypress/tsconfig.json
@@ -0,0 +1,16 @@
+{
+ "compilerOptions": {
+ "target": "es5",
+ "lib": [
+ "es5",
+ "dom"
+ ],
+ "types": [
+ "cypress"
+ ],
+ "isolatedModules": false,
+ },
+ "include": [
+ "**/*.ts"
+ ]
+} \ No newline at end of file