Skip to content

Commit

Permalink
Add jsdom to jbrowse-img to fix --noRasterize option (#3009)
Browse files Browse the repository at this point in the history
* Add jsdom for noRasterize

* Use plain node instead of jsdom environment when testing jbrowse/img
  • Loading branch information
cmdcolin committed Jun 7, 2022
1 parent 9a4531b commit 8df7c74
Show file tree
Hide file tree
Showing 8 changed files with 168 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"check-format": "prettier --check .",
"typecheck": "tsc --noEmit",
"pretest-ci": "cd products/jbrowse-react-linear-genome-view;yarn build;cd ../../",
"test-ci": "cross-env NODE_OPTIONS='--max-old-space-size=7000' jest --ci --coverage && jest --testMatch '**/*testmod.js'",
"test-ci": "cross-env NODE_OPTIONS='--max-old-space-size=7000' jest --ci --coverage && jest --env node --testMatch '**/*testmod.js'",
"built-test-ci": "jest --ci integration.test.js",
"test": "jest"
},
Expand Down
1 change: 1 addition & 0 deletions products/jbrowse-img/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@jbrowse/plugin-linear-genome-view": "^1.7.9",
"@jbrowse/react-linear-genome-view": "^1.7.9",
"abortcontroller-polyfill": "^1.7.3",
"jsdom": "^19.0.0",
"mobx": "^5.10.1",
"node-fetch": "^2.6.7",
"react": "^17.0.1",
Expand Down
4 changes: 4 additions & 0 deletions products/jbrowse-img/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import tmp from 'tmp'
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'
import { spawnSync } from 'child_process'
import fetch, { Headers, Response, Request } from 'node-fetch'
import { JSDOM } from 'jsdom'

const { document } = new JSDOM(`...`).window
global.document = document

if (!global.fetch) {
global.fetch = fetch
Expand Down
54 changes: 43 additions & 11 deletions products/jbrowse-img/src/index.testmod.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { renderRegion } from './renderRegion'
import fs from 'fs'
import { JSDOM } from 'jsdom'
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'

const { document } = new JSDOM(`...`).window
global.document = document

function hashCode(str) {
let hash = 0
Expand Down Expand Up @@ -49,20 +54,18 @@ xtest(
test(
'renders volvox with variety of args',
async () => {
const fp = f => require.resolve('../data/volvox/' + f)
console.error = jest.fn()
const result = await renderRegion({
fasta: require.resolve('../data/volvox/volvox.fa'),
fasta: fp('volvox.fa'),
trackList: [
['bam', [require.resolve('../data/volvox/volvox-sorted.bam')]],
['cram', [require.resolve('../data/volvox/volvox-sorted.cram')]],
[
'bigwig',
[require.resolve('../data/volvox/volvox-sorted.bam.coverage.bw')],
],
['vcfgz', [require.resolve('../data/volvox/volvox.filtered.vcf.gz')]],
['gffgz', [require.resolve('../data/volvox/volvox.sort.gff3.gz')]],
['bigbed', [require.resolve('../data/volvox/volvox.bb')]],
['bedgz', [require.resolve('../data/volvox/volvox-bed12.bed.gz')]],
['bam', [fp('volvox-sorted.bam')]],
['cram', [fp('volvox-sorted.cram')]],
['bigwig', [fp('volvox-sorted.bam.coverage.bw')]],
['vcfgz', [fp('volvox.filtered.vcf.gz')]],
['gffgz', [fp('volvox.sort.gff3.gz')]],
['bigbed', [fp('volvox.bb')]],
['bedgz', [fp('volvox-bed12.bed.gz')]],
],
loc: 'ctgA:1000-2000',
})
Expand All @@ -76,6 +79,35 @@ test(
timeout,
)

test(
'renders volvox with variety of args (noRasterize)',
async () => {
const fp = f => require.resolve('../data/volvox/' + f)
console.error = jest.fn()
const result = await renderRegion({
fasta: fp('volvox.fa'),
trackList: [
['bam', [fp('volvox-sorted.bam')]],
['cram', [fp('volvox-sorted.cram')]],
['bigwig', [fp('volvox-sorted.bam.coverage.bw')]],
['vcfgz', [fp('volvox.filtered.vcf.gz')]],
['gffgz', [fp('volvox.sort.gff3.gz')]],
['bigbed', [fp('volvox.bb')]],
['bedgz', [fp('volvox-bed12.bed.gz')]],
],
loc: 'ctgA:1000-2000',
noRasterize: true,
})
// can't do a snapshot test here, slightly inconsistent results(?)
fs.writeFileSync(
require.resolve('../test/svg_from_volvox_fasta_and_bam_norasterize.svg'),
result,
)
expect(result).toBeTruthy()
},
timeout,
)

// commented out for using remote files currently
xtest(
'configtracks arg with urls',
Expand Down
2 changes: 1 addition & 1 deletion products/jbrowse-img/test/svg_configtracks_local.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
119 changes: 116 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5174,7 +5174,7 @@ JSONStream@^1.0.4:
jsonparse "^1.2.0"
through ">=2.2.7 <3"

abab@^2.0.3, abab@^2.0.5:
abab@^2.0.3, abab@^2.0.5, abab@^2.0.6:
version "2.0.6"
resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.6.tgz#41b80f2c871d19686216b82309231cfd3cb3d291"
integrity sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA==
Expand Down Expand Up @@ -7870,6 +7870,11 @@ cssom@^0.4.4:
resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.4.4.tgz#5a66cf93d2d0b661d80bf6a44fb65f5c2e4e0a10"
integrity sha512-p3pvU7r1MyyqbTk+WbNJIgJjG2VmTIaB10rI93LzVPrmDJKkzKYMtxxyAvQXR/NS6otuzveI7+7BBq3SjBS2mw==

cssom@^0.5.0:
version "0.5.0"
resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.5.0.tgz#d254fa92cd8b6fbd83811b9fbaed34663cc17c36"
integrity sha512-iKuQcq+NdHqlAcwUY0o/HL69XQrUaQdMjmStJ8JFmUaiiQErlhrmuigkg/CU4E2J0IyUKUrMAgl36TvN67MqTw==

cssom@~0.3.6:
version "0.3.8"
resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.3.8.tgz#9f1276f5b2b463f2114d3f2c75250af8c1a36f4a"
Expand Down Expand Up @@ -7983,6 +7988,15 @@ data-urls@^2.0.0:
whatwg-mimetype "^2.3.0"
whatwg-url "^8.0.0"

data-urls@^3.0.1:
version "3.0.2"
resolved "https://registry.yarnpkg.com/data-urls/-/data-urls-3.0.2.tgz#9cf24a477ae22bcef5cd5f6f0bfbc1d2d3be9143"
integrity sha512-Jy/tj3ldjZJo63sVAvg6LHt2mHvl4V6AgRAmNDtLdm7faqtsx+aJG42rsyCo9JCoRVKwPFzKlIPx3DIibwSIaQ==
dependencies:
abab "^2.0.6"
whatwg-mimetype "^3.0.0"
whatwg-url "^11.0.0"

date-fns@^2.16.1:
version "2.28.0"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.28.0.tgz#9570d656f5fc13143e50c975a3b6bbeb46cd08b2"
Expand Down Expand Up @@ -8037,7 +8051,7 @@ decamelize@^1.1.0, decamelize@^1.1.2:
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
integrity sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==

decimal.js@^10.2.1:
decimal.js@^10.2.1, decimal.js@^10.3.1:
version "10.3.1"
resolved "https://registry.yarnpkg.com/decimal.js/-/decimal.js-10.3.1.tgz#d8c3a444a9c6774ba60ca6ad7261c3a94fd5e783"
integrity sha512-V0pfhfr8suzyPGOx3nmq4aHqabehUZn6Ch9kyFpV79TGDTWFmHqUqXdabR7QHqxzrYolF4+tVmJhUG4OURg5dQ==
Expand Down Expand Up @@ -8461,6 +8475,13 @@ domexception@^2.0.1:
dependencies:
webidl-conversions "^5.0.0"

domexception@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/domexception/-/domexception-4.0.0.tgz#4ad1be56ccadc86fc76d033353999a8037d03673"
integrity sha512-A2is4PLG+eeSfoTMA95/s4pvAoSo2mKtiM5jlHkAVewmiO8ISFTFKZjH7UAM1Atli/OT/7JHOrJRJiMKUZKYBw==
dependencies:
webidl-conversions "^7.0.0"

domhandler@^4.0.0, domhandler@^4.2.0, domhandler@^4.3.1:
version "4.3.1"
resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-4.3.1.tgz#8d792033416f59d68bc03a5aa7b018c1ca89279c"
Expand Down Expand Up @@ -10726,6 +10747,13 @@ html-encoding-sniffer@^2.0.1:
dependencies:
whatwg-encoding "^1.0.5"

html-encoding-sniffer@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz#2cb1a8cf0db52414776e5b2a7a04d5dd98158de9"
integrity sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA==
dependencies:
whatwg-encoding "^2.0.0"

html-entities@^2.1.0, html-entities@^2.3.2:
version "2.3.3"
resolved "https://registry.yarnpkg.com/html-entities/-/html-entities-2.3.3.tgz#117d7626bece327fc8baace8868fa6f5ef856e46"
Expand Down Expand Up @@ -10980,7 +11008,7 @@ iconv-lite@0.4.24, iconv-lite@^0.4.24:
dependencies:
safer-buffer ">= 2.1.2 < 3"

iconv-lite@^0.6.2, iconv-lite@^0.6.3:
iconv-lite@0.6.3, iconv-lite@^0.6.2, iconv-lite@^0.6.3:
version "0.6.3"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.3.tgz#a52f80bf38da1952eb5c681790719871a1a72501"
integrity sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==
Expand Down Expand Up @@ -12464,6 +12492,39 @@ jsdom@^16.6.0:
ws "^7.4.6"
xml-name-validator "^3.0.0"

jsdom@^19.0.0:
version "19.0.0"
resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-19.0.0.tgz#93e67c149fe26816d38a849ea30ac93677e16b6a"
integrity sha512-RYAyjCbxy/vri/CfnjUWJQQtZ3LKlLnDqj+9XLNnJPgEGeirZs3hllKR20re8LUZ6o1b1X4Jat+Qd26zmP41+A==
dependencies:
abab "^2.0.5"
acorn "^8.5.0"
acorn-globals "^6.0.0"
cssom "^0.5.0"
cssstyle "^2.3.0"
data-urls "^3.0.1"
decimal.js "^10.3.1"
domexception "^4.0.0"
escodegen "^2.0.0"
form-data "^4.0.0"
html-encoding-sniffer "^3.0.0"
http-proxy-agent "^5.0.0"
https-proxy-agent "^5.0.0"
is-potential-custom-element-name "^1.0.1"
nwsapi "^2.2.0"
parse5 "6.0.1"
saxes "^5.0.1"
symbol-tree "^3.2.4"
tough-cookie "^4.0.0"
w3c-hr-time "^1.0.2"
w3c-xmlserializer "^3.0.0"
webidl-conversions "^7.0.0"
whatwg-encoding "^2.0.0"
whatwg-mimetype "^3.0.0"
whatwg-url "^10.0.0"
ws "^8.2.3"
xml-name-validator "^4.0.0"

jsesc@^2.5.1:
version "2.5.2"
resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4"
Expand Down Expand Up @@ -18426,6 +18487,13 @@ tr46@^2.1.0:
dependencies:
punycode "^2.1.1"

tr46@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/tr46/-/tr46-3.0.0.tgz#555c4e297a950617e8eeddef633c87d4d9d6cbf9"
integrity sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==
dependencies:
punycode "^2.1.1"

tr46@~0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a"
Expand Down Expand Up @@ -19108,6 +19176,13 @@ w3c-xmlserializer@^2.0.0:
dependencies:
xml-name-validator "^3.0.0"

w3c-xmlserializer@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/w3c-xmlserializer/-/w3c-xmlserializer-3.0.0.tgz#06cdc3eefb7e4d0b20a560a5a3aeb0d2d9a65923"
integrity sha512-3WFqGEgSXIyGhOmAFtlicJNMjEps8b1MG31NCA0/vOF9+nKMUW1ckhi9cnNHmf88Rzw5V+dwIwsm2C7X8k9aQg==
dependencies:
xml-name-validator "^4.0.0"

wait-on@^6.0.0:
version "6.0.1"
resolved "https://registry.yarnpkg.com/wait-on/-/wait-on-6.0.1.tgz#16bbc4d1e4ebdd41c5b4e63a2e16dbd1f4e5601e"
Expand Down Expand Up @@ -19189,6 +19264,11 @@ webidl-conversions@^6.1.0:
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-6.1.0.tgz#9111b4d7ea80acd40f5270d666621afa78b69514"
integrity sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w==

webidl-conversions@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-7.0.0.tgz#256b4e1882be7debbf01d05f0aa2039778ea080a"
integrity sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==

webpack-cli@^4.9.1:
version "4.9.2"
resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-4.9.2.tgz#77c1adaea020c3f9e2db8aad8ea78d235c83659d"
Expand Down Expand Up @@ -19405,6 +19485,13 @@ whatwg-encoding@^1.0.5:
dependencies:
iconv-lite "0.4.24"

whatwg-encoding@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/whatwg-encoding/-/whatwg-encoding-2.0.0.tgz#e7635f597fd87020858626805a2729fa7698ac53"
integrity sha512-p41ogyeMUrw3jWclHWTQg1k05DSVXPLcVxRTYsXUk+ZooOCZLcoYgPZ/HL/D/N+uQPOtcp1me1WhBEaX02mhWg==
dependencies:
iconv-lite "0.6.3"

whatwg-fetch@^3.6.2:
version "3.6.2"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.6.2.tgz#dced24f37f2624ed0281725d51d0e2e3fe677f8c"
Expand All @@ -19415,6 +19502,27 @@ whatwg-mimetype@^2.3.0:
resolved "https://registry.yarnpkg.com/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz#3d4b1e0312d2079879f826aff18dbeeca5960fbf"
integrity sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g==

whatwg-mimetype@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/whatwg-mimetype/-/whatwg-mimetype-3.0.0.tgz#5fa1a7623867ff1af6ca3dc72ad6b8a4208beba7"
integrity sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==

whatwg-url@^10.0.0:
version "10.0.0"
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-10.0.0.tgz#37264f720b575b4a311bd4094ed8c760caaa05da"
integrity sha512-CLxxCmdUby142H5FZzn4D8ikO1cmypvXVQktsgosNy4a4BHrDHeciBBGZhb0bNoR5/MltoCatso+vFjjGx8t0w==
dependencies:
tr46 "^3.0.0"
webidl-conversions "^7.0.0"

whatwg-url@^11.0.0:
version "11.0.0"
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-11.0.0.tgz#0a849eebb5faf2119b901bb76fd795c2848d4018"
integrity sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ==
dependencies:
tr46 "^3.0.0"
webidl-conversions "^7.0.0"

whatwg-url@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d"
Expand Down Expand Up @@ -19795,6 +19903,11 @@ xml-name-validator@^3.0.0:
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"
integrity sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==

xml-name-validator@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-4.0.0.tgz#79a006e2e63149a8600f15430f0a4725d1524835"
integrity sha512-ICP2e+jsHvAj2E2lIHxa5tjXRlKDJo4IdvPvCXbXQGdzSfmSpNVyIKMvoZHjDY9DP0zV17iI85o90vRFXNccRw==

xmlbuilder@>=11.0.1:
version "15.1.1"
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-15.1.1.tgz#9dcdce49eea66d8d10b42cae94a79c3c8d0c2ec5"
Expand Down

0 comments on commit 8df7c74

Please sign in to comment.