Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature][WIP] Introduce cypress #74

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
5 changes: 5 additions & 0 deletions cypress/integration/sample_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('Sample Test', () => {
it('go to any repository pages', () => {
cy.visit('https://github.com/shinenic/a-tree')
})
})
14 changes: 14 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const path = require('path')

// @FIXME Correct the path
const BUILD_PATH = path.resolve(__dirname, '..', '..', 'dist')

module.exports = (on) => {
on('before:browser:launch', (browser, launchOptions) => {
console.log('launching browser %o', browser)

launchOptions.extensions.push(BUILD_PATH)

return launchOptions
})
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"babel-plugin-lodash": "^3.3.4",
"copy-webpack-plugin": "^9.0.1",
"cross-env": "^7.0.3",
"cypress": "^9.1.1",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-plugin-import": "^2.24.2",
Expand All @@ -91,9 +92,9 @@
"eslint-plugin-simple-import-sort": "^7.0.0",
"file-icons-js": "websemantics/file-icons-js",
"html-webpack-plugin": "^5.3.2",
"jquery-pjax": "^2.0.1",
"jest": "^27.4.3",
"jest-puppeteer": "^6.0.2",
"jquery-pjax": "^2.0.1",
"lodash-webpack-plugin": "^0.11.6",
"prettier-eslint": "^13.0.0",
"puppeteer": "^13.0.0",
Expand Down
19 changes: 19 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@ import MainThemeProvider from 'styles/Provider'

import App from './App'

/**
* @FIXME
* If we want to use `cypress` to test the extension,
* need to notice that cypress test the target window in a `iframe`,
* so all of the dom operations & queries have to be done in the `iframe`.
*
* (This is a sample solution)
*/
const handleCypressTesting = () => {
const iframeWindow = window.document
.querySelector('iframe')
.contentWindow.document.createElement('div')

// eslint-disable-next-line
window._window = iframeWindow
// eslint-disable-next-line
window._document = iframeWindow.document
}

const checkDomainMatched = (domains) => {
const { host } = window.location

Expand Down
Loading