You shouldn't even need to copy it to a text file. A better solution should be to just get the text of the element in question and assert directly on it using
.should('eq', expectedTextValue)
or something like that. No intermediary file writing is needed.