Dealing with on unit testing
Sometimes we need to use
in our HTML as opposed to a space. However because
has a different byte code, the comparison between
and a space will always return false. That’s why if we want to do assertion with an HTML text containing
characters, we need to replace spaces with \u00a0
(
will be transformed to unix code when rendered).
const mount = function render() {
return <p> </p>;
};
const wrapper = mount();
expect(wrapper.text()).toBe(" "); // false
expect(wrapper.text()).toBe("\u00a0"); // true