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

Behaviour difference between platforms #77

Open
theophilusx opened this issue Jan 23, 2020 · 0 comments
Open

Behaviour difference between platforms #77

theophilusx opened this issue Jan 23, 2020 · 0 comments

Comments

@theophilusx
Copy link

I'm using chai subset in some tests which compare the output from a directory listing. Under Linux, the tests were passing fine, but under Windows (win10), the comparison was failing. The issue turned out to be due to an ordering problem.

It seems that order within containsSubset does not matter under Linux, but does matter under win32. To fix the issue, I altered the ordering within the test and it works on both platforms. As this is different behavior based on platform differences (node vesions and chai/mocha vesions the same), I thought it should be reported.

Example

The following test was passing on Linux, but failing on win32

  it('Uploaded top-level files', async function() {
    let remoteDir = makeRemotePath(config.sftpUrl, 'upload-test');
    let fileList = await sftp.list(remoteDir);
    return expect(fileList).to.containSubset([
      {name: 'file1.txt', type: '-', size: 6973257},
      {name: 'file2.txt.gz', type: '-', size: 570314},
      {name: 'sub1', type: 'd'},
      {name: 'sub3', type: 'd'}
    ]);
  });

but changing it to the following and the test works on both platforms

  it('Uploaded top-level files', async function() {
    let remoteDir = makeRemotePath(config.sftpUrl, 'upload-test');
    let fileList = await sftp.list(remoteDir);
    return expect(fileList).to.containSubset([
      {name: 'file2.txt.gz', type: '-', size: 570314},
      {name: 'sub1', type: 'd'},
      {name: 'sub3', type: 'd'},
      {name: 'file1.txt', type: '-', size: 6973257}
    ]);
  });

Node version 12.14.1

"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"chai-subset": "^1.6.0",
"mocha": "^7.0.0",

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

1 participant