Jsdom: ReferenceError: Blob์ด ์ •์˜๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.

์— ๋งŒ๋“  2018๋…„ 04์›” 16์ผ  ยท  3์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: jsdom/jsdom

๊ธฐ๋ณธ ์ •๋ณด:

  • Node.js ๋ฒ„์ „: 6.12.3
  • jsdom ๋ฒ„์ „: 11.6.2

์ตœ์†Œํ•œ์˜ ์žฌ์ƒ์‚ฐ ์ผ€์ด์Šค

  • ํ…Œ์ŠคํŠธ
import { spy } from "sinon";
import SaveBtn from "../../../app/component/SaveBtn";

const onClickSpy = spy(SaveBtn.prototype, "onClick");

const SaveBtnTest = describe("Testing Submit Button component", function () {
    const SaveBtnElement = renderComponent(SaveBtn);
    ...
    it("should call the submit handler when clicked", function () {
        SaveBtnElement.find("button").simulate("click");
        assert(onClickSpy.calledOnce, true);
    });
});
  • ๊ตฌ์„ฑ
const jsdom      = new JSDOM("<!DOCTYPE HTML><html><body></body></html>");
global.window    = jsdom.window;
global.document  = jsdom.window.document;
global.navigator = {
    userAgent: "node.js"
};
...
  • ์š”์†Œ
...
onClick() {
    const blob = new Blob([ this.props.code ], {
        type: "text/plain;charset=ascii"
    });
    ...
}

๋ชจ๋“  3 ๋Œ“๊ธ€

https://github.com/jsdom/jsdom/wiki/Don 't-stuff-jsdom-globals-onto-the-Node-global์„ ์ฐธ์กฐ

@Sebmaster ๋‹ต๋ณ€ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ๋‚˜๋Š” onClick ํ•ธ๋“ค๋Ÿฌ ๋ฉ”์†Œ๋“œ๋ฅผ ์‹ค์ œ๋กœ ํ˜ธ์ถœํ•˜์ง€ ์•Š๊ณ , ์ฆ‰ _fake ํ•ธ๋“ค๋Ÿฌ_๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํ˜ธ์ถœ๋˜๊ณ  ์žˆ๋Š”์ง€ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ๋Š”์ง€ ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค.

์žˆ์„ ์ˆ˜๋„ ์žˆ์ง€๋งŒ ๊ทธ ์งˆ๋ฌธ์€ ์—ฌ๊ธฐ๋ณด๋‹ค StackOverflow์— ๋” ์ ํ•ฉํ•ฉ๋‹ˆ๋‹ค. ์ฃ„์†กํ•ฉ๋‹ˆ๋‹ค.

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰