Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests actual vs expected output is hardly readable #2514

Closed
f1ames opened this issue Sep 19, 2018 · 4 comments · Fixed by ckeditor/ckeditor5-utils#302
Closed

Tests actual vs expected output is hardly readable #2514

f1ames opened this issue Sep 19, 2018 · 4 comments · Fixed by ckeditor/ckeditor5-utils#302
Labels
package:paste-from-office type:task This issue reports a chore (non-production change) and other types of "todos".

Comments

@f1ames
Copy link
Contributor

f1ames commented Sep 19, 2018

At the current state, unit tests (both normalization and integration tests) use the regular expect which compares two strings. While for integration tests it is somehow acceptable (because compared content is rather short), for normalization tests the output is usually unreadable:

image

It will be good to employ some diffing mechanism which will highlight the parts which are different (or any other reasonable mechanism to make the output readable).

@Reinmar
Copy link
Member

Reinmar commented Sep 19, 2018

I think this may be a ckeditor5-dev ticket. Some smarter diff would be indeed welcome.

@Reinmar
Copy link
Member

Reinmar commented Sep 19, 2018

cc @pomek

@jodator
Copy link
Contributor

jodator commented Sep 19, 2018

For that reason I've created simple formatting mechanism in tables (table centric only):
selection_046

I would love to have something smarter (more like diffs on github). 👏

@jodator
Copy link
Contributor

jodator commented Sep 5, 2019

@Reinmar I get annoyed by the output of the PFO tests:

Selection_027

Go and find what's wrong here (it's a single space).

So I've fiddle out with https://www.npmjs.com/package/js-beautify in PFO tests:

const b = string => beautify.html_beautify( string, { indent_size: 2, space_in_empty_paren: true } );
expect( b( actualModel.replace( /\u00A0/g, ' ' ) ) ).to.equal( b( expectedModel ) );

if ( actualImages.length > 0 && expectedImages.length > 0 ) {
	expect( actualImages.length ).to.equal( expectedImages.length );
	expect( actualImages ).to.deep.equal( expectedImages );
}

and got this:
Selection_026

It is the similar approach I've used with tables - format the HTML string. It plays nice with the mocha's differ and we could introduce it as some test util that enhance expects:

compareHTML( expected, actual );

ps.: It should play well with model strings (I check it with some table model structure).

Reinmar referenced this issue in ckeditor/ckeditor5-utils Sep 17, 2019
Feature: Introduce `assertEqualMarkup()` test util method. Closes ckeditor/ckeditor5-paste-from-office#14.
@mlewand mlewand transferred this issue from ckeditor/ckeditor5-paste-from-office Oct 9, 2019
@mlewand mlewand added this to the backlog milestone Oct 9, 2019
@mlewand mlewand added status:confirmed type:task This issue reports a chore (non-production change) and other types of "todos". package:paste-from-office labels Oct 9, 2019
@mlewand mlewand modified the milestones: backlog, iteration 27 Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:paste-from-office type:task This issue reports a chore (non-production change) and other types of "todos".
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants