This repository was archived by the owner on Mar 5, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change 1
1
const debug = require ( 'debug' ) ( 'cypress-react-unit-test' )
2
2
const path = require ( 'path' )
3
3
const mime = require ( 'mime-types' )
4
+ const fs = require ( 'fs' )
4
5
5
6
/**
6
7
* User code:
@@ -10,7 +11,7 @@ const mime = require('mime-types')
10
11
* image is "/__root/path/to/image.png"
11
12
* <img src={image} />
12
13
*/
13
- function staticResourceLoader ( content ) {
14
+ function staticResourceLoader ( ) {
14
15
debug ( 'loading static resource %s' , this . resourcePath )
15
16
debug ( 'cwd' , process . cwd ( ) )
16
17
const relativeResourcePath = path . relative ( process . cwd ( ) , this . resourcePath )
@@ -20,7 +21,8 @@ function staticResourceLoader(content) {
20
21
debug ( 'resource is outside of the current working directory' )
21
22
debug ( 'inlining it instead (performance hit!)' )
22
23
const mimetype = mime . lookup ( this . resourcePath )
23
- const encoded = content . toString ( 'base64' )
24
+ const content = fs . readFileSync ( this . resourcePath )
25
+ const encoded = new Buffer ( content ) . toString ( 'base64' )
24
26
return `module.exports = "data:${ mimetype } ;base64,${ encoded } "`
25
27
}
26
28
You can’t perform that action at this time.
0 commit comments