Skip to content
Closed
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
21 changes: 20 additions & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
const webpackPreprocessor = require('@cypress/webpack-batteries-included-preprocessor')

function getWebpackOptions () {
const options = webpackPreprocessor.getFullWebpackOptions()

options.resolve.fallback.crypto = require.resolve('crypto-browserify')

return options
}

module.exports = {
e2e: {
setupNodeEvents(on, config) {},
setupNodeEvents(on, config) {
on(
'file:preprocessor',
webpackPreprocessor({
// if using typescript, you will need to set the typescript option to true
typescript: true,
webpackOptions: getWebpackOptions(),
}),
);
},
},
}
1 change: 1 addition & 0 deletions cypress/e2e/spec.cy.js → cypress/e2e/spec.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
describe('page', () => {
it('works', () => {
cy.visit('https://example.cypress.io')
cy.crypto().should('eq', 'some-secret')
})
})
8 changes: 8 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import crypto from 'crypto';

// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
Expand All @@ -23,3 +25,9 @@
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

Cypress.Commands.add("crypto", () => {
return crypto.createHmac('sha256', 'some-secret')
.update('I love cupcakes')
.digest('hex');
})
Loading