Skip to content

Commit 6e2a60e

Browse files
Merge branch 'develop' into release/15.0.0
2 parents d5d890f + 4127264 commit 6e2a60e

File tree

9 files changed

+129
-1
lines changed

9 files changed

+129
-1
lines changed

packages/driver/src/cypress.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ class $Cypress {
173173
sinon = sinon
174174
lolex = fakeTimers
175175

176+
areSourceMapsAvailable: boolean = false
177+
176178
static $: any
177179
static utils: any
178180

@@ -188,7 +190,7 @@ class $Cypress {
188190
this.primaryOriginCommunicator = new PrimaryOriginCommunicator()
189191
this.specBridgeCommunicator = new SpecBridgeCommunicator()
190192
this.isCrossOriginSpecBridge = false
191-
193+
this.areSourceMapsAvailable = false
192194
this.events = $Events.extend(this)
193195
this.$ = jqueryProxyFn.bind(this)
194196

@@ -365,13 +367,15 @@ class $Cypress {
365367

366368
this.events.proxyTo(this.cy)
367369

370+
this.areSourceMapsAvailable = false
368371
$scriptUtils.runScripts({
369372
browser: this.config('browser'),
370373
scripts,
371374
specWindow,
372375
testingType: this.testingType,
373376
})
374377
.then(() => {
378+
this.areSourceMapsAvailable = $sourceMapUtils.areSourceMapsAvailable()
375379
if (this.testingType === 'e2e') {
376380
return setSpecContentSecurityPolicy(specWindow)
377381
}

packages/driver/src/cypress/source_map_utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,15 @@ const destroySourceMapConsumers = () => {
114114
sourceMapConsumers = {}
115115
}
116116

117+
const areSourceMapsAvailable = () => {
118+
return Object.keys(sourceMapConsumers).length > 0
119+
}
120+
117121
export default {
118122
getSourcePosition,
119123
getSourceContents,
120124
extractSourceMap,
121125
initializeSourceMapConsumer,
122126
destroySourceMapConsumers,
127+
areSourceMapsAvailable,
123128
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
e2e: {
3+
supportFile: false,
4+
setupNodeEvents (on, config) {
5+
require('./cypress-preprocessor.config.js')(on, config)
6+
},
7+
},
8+
env: {
9+
areSourceMapsAvailable: false,
10+
},
11+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
e2e: {
3+
supportFile: false,
4+
setupNodeEvents (on, config) {
5+
},
6+
},
7+
env: {
8+
areSourceMapsAvailable: true,
9+
},
10+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const webpack = require('@cypress/webpack-preprocessor')
2+
3+
module.exports = (on, config) => {
4+
const options = {
5+
webpackOptions: {
6+
devtool: false, // This disables sourcemaps
7+
resolve: {
8+
extensions: ['.js', '.ts', '.jsx', '.tsx'],
9+
},
10+
module: {
11+
rules: [
12+
{
13+
test: /\.ts$/,
14+
exclude: [/node_modules/],
15+
use: [
16+
{
17+
loader: 'ts-loader',
18+
options: {
19+
transpileOnly: true,
20+
},
21+
},
22+
],
23+
},
24+
],
25+
},
26+
},
27+
watchOptions: {},
28+
}
29+
30+
on('file:preprocessor', webpack(options))
31+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
it('should validate sourcemaps', () => {
2+
expect(Cypress.areSourceMapsAvailable).to.be[Cypress.env('areSourceMapsAvailable')]
3+
})
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "sourcemaps",
3+
"version": "0.0.0-test",
4+
"devDependencies": {
5+
"@cypress/webpack-preprocessor": "file:../../../npm/webpack-preprocessor"
6+
}
7+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
"@cypress/webpack-preprocessor@file:../../../npm/webpack-preprocessor":
6+
version "0.0.0-development"
7+
dependencies:
8+
bluebird "3.7.1"
9+
debug "^4.3.4"
10+
lodash "^4.17.20"
11+
semver "^7.3.2"
12+
13+
14+
version "3.7.1"
15+
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.1.tgz#df70e302b471d7473489acf26a93d63b53f874de"
16+
integrity sha512-DdmyoGCleJnkbp3nkbxTLJ18rjDsE4yCggEwKNXkeV123sPNfOCYeDoeuOY+F2FrSjO1YXcTU+dsy96KMy+gcg==
17+
18+
debug@^4.3.4:
19+
version "4.4.1"
20+
resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.1.tgz#e5a8bc6cbc4c6cd3e64308b0693a3d4fa550189b"
21+
integrity sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==
22+
dependencies:
23+
ms "^2.1.3"
24+
25+
lodash@^4.17.20:
26+
version "4.17.21"
27+
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
28+
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
29+
30+
ms@^2.1.3:
31+
version "2.1.3"
32+
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2"
33+
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==
34+
35+
semver@^7.3.2:
36+
version "7.7.2"
37+
resolved "https://registry.yarnpkg.com/semver/-/semver-7.7.2.tgz#67d99fdcd35cec21e6f8b87a7fd515a33f982b58"
38+
integrity sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==

system-tests/test/sourcemaps_spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import systemTests from '../lib/system-tests'
2+
3+
describe('e2e sourcemaps', () => {
4+
systemTests.setup()
5+
6+
systemTests.it('detects sourcemaps as enabled', {
7+
browser: '!webkit',
8+
project: 'sourcemaps',
9+
spec: 'validate-sourcemaps.cy.js',
10+
configFile: 'cypress-enabled.config.js',
11+
})
12+
13+
systemTests.it('detects sourcemaps as disabled', {
14+
browser: '!webkit',
15+
project: 'sourcemaps',
16+
spec: 'validate-sourcemaps.cy.js',
17+
configFile: 'cypress-disabled.config.js',
18+
})
19+
})

0 commit comments

Comments
 (0)