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

assert.any #4

Open
raftheunis87 opened this issue Jan 12, 2016 · 7 comments
Open

assert.any #4

raftheunis87 opened this issue Jan 12, 2016 · 7 comments

Comments

@raftheunis87
Copy link

Hey,

First of all, thanks for this library! It really makes testing streams a joy :-).

I got a problem with the any assertion. Maybe I'm using the wrong syntax. What I try to do is the following:

this.source = vinylFs.src(['test/specs/streams/**'], {nodir: true});
it('should test if the files are in the stream', function (done) {
    this.source
      .pipe(assert.any(function (file) {
        expect(file.path).toContain('include_me.css');
      }))
      .on('assertion', function (err) {
        done.fail(err);
      })
      .pipe(pi.devnull(function () {
        done();
      }));
  });

The problem is that it is checking all the files in the stream against the 'include_me.css'. I get the following output:

A copy stream should test if the files are in the stream
  - Expected '/test/specs/streams/copy/resources/src/shared/style/include_me_2.css' to contain 'include_me.css'.
  - Expected 'test/specs/streams/copy/resources/src/authenticated/style/img/included.jpg' to contain 'include_me.css'.
  - Expected 'test/specs/streams/copy/resources/src/shared/style/img/included.jpg' to contain 'include_me.css'.

The 'include_me.css' is also in this filepath as well, but it is not logged as an error because it matches.

What can I do to resolve this issue?

Kind regards,

Raf

@floatdrop
Copy link
Owner

@raftheunis87 seems like expect(file.path).toContain('include_me.css'); is printing out Exprecetd... on every call. You can look into expect library for a way to disable this logging.

@raftheunis87
Copy link
Author

@floatdrop Thanks for the quick reply.

It's not just the logging, the test is actually failing :-(

@floatdrop
Copy link
Owner

@raftheunis87 can you print error message in assertion event?

@raftheunis87
Copy link
Author

@floatdrop

.on('assertion', function (err) {
        console.log(err);
        done.fail(err);
      })

The console.log is not printed, so I guess the event doesn't happen. But it's weird that I get the following output:

A copy stream should test if the files are in the stream
  - Expected '/test/specs/streams/copy/resources/src/shared/style/include_me_2.css' to contain 'include_me.css'.
  - Expected 'test/specs/streams/copy/resources/src/authenticated/style/img/included.jpg' to contain 'include_me.css'.
  - Expected 'test/specs/streams/copy/resources/src/shared/style/img/included.jpg' to contain 'include_me.css'.

To me it seems like he is matching against all the files in the stream, even if there was a match with one of them? I would expect that when 1 of the files matches, that it doesn't matter anymore if any of the other files match, right?

@floatdrop
Copy link
Owner

I would expect that when 1 of the files matches, that it doesn't matter anymore if any of the other files match, right?

@raftheunis87 didn't think about it, but it does make sense.

@raftheunis87
Copy link
Author

@floatdrop Is this going to be fixed? Or should I look into it and create a pull request? :)

@floatdrop
Copy link
Owner

@raftheunis87 PR would be awesome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants