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

Some tests fails on Windows #5290

Open
Juraj-Masiar opened this issue May 14, 2024 · 0 comments
Open

Some tests fails on Windows #5290

Juraj-Masiar opened this issue May 14, 2024 · 0 comments

Comments

@Juraj-Masiar
Copy link

Juraj-Masiar commented May 14, 2024

Describe the problem and steps to reproduce it:

Following the build instructions using Windows 11:

git clone https://github.com/mozilla/addons-linter.git
cd addons-linter
npm install
# Build the project.
npm run build
# Run the test-suite and watch for changes. Use `npm run test-once` to
# just run it once.
npm run test

What happened?

C:\Users\juraj\git\addons\_os\addons-linter>npm run test-once

> addons-linter@6.27.0 test-once
> jest --runInBand

 FAIL  tests/unit/parsers/test.manifestjson.js
  ● ManifestJSONParser › locales › emits an error when messages.json is missing in language directory

    expect(received).toEqual(expected) // deep equality

    - Expected  - 2
    + Received  + 8

    - ObjectContaining {
    + Message {
    +   "_type": "error",
        "code": "NO_MESSAGES_FILE_IN_LOCALES",
    -   "description": StringMatching /file missing in "_locales\/hi"/,
    +   "column": undefined,
    +   "description": "messages.json file missing in \"_locales\\hi\"",
    +   "file": "manifest.json",
    +   "instancePath": undefined,
    +   "line": undefined,
    +   "message": "Empty language directory",
      }

      4129 |       const { errors } = addonLinter.collector;
      4130 |       expect(errors.length).toEqual(3);
    > 4131 |       expect(errors[0]).toEqual(
           |                         ^
      4132 |         expect.objectContaining({
      4133 |           code: messages.NO_MESSAGES_FILE_IN_LOCALES,
      4134 |           description: expect.stringMatching(`file missing in "_locales/hi"`),

      at Object.toEqual (tests/unit/parsers/test.manifestjson.js:4131:25)

 FAIL  tests/unit/test.linter.js
  ● Console

    console.error
      Selected file(s) not found: subdir/test3.js, subdir/test4.js

      135 |       _console.error(err.stack);
      136 |     } else {
    > 137 |       _console.error(this.chalk.red(err.message || err));
          |                ^
      138 |     }
      139 |
      140 |     this.closeIO();

      at Linter.error [as handleError] (src/linter.js:137:16)
      at Linter.handleError [as scan] (src/linter.js:593:16)
      at Object.<anonymous> (tests/unit/test.linter.js:284:5)

    console.log
      Validation Summary:

      errors          1
      notices         0
      warnings        0

      ERRORS:

      Code                    Message       Description              File   Line   Column
      TYPE_NO_MANIFEST_JSON   manifest.j…   No manifest.json was
                              son was not   found at the root of
                              found         the extension. The
                                            package file must be a
                                            ZIP of the extension's
                                            files themselves, not
                                            of the containing
                                            directory. See:
                                            https://mzl.la/2r2McKv
                                            for more on packaging.

      at Linter.log [as print] (src/linter.js:152:16)

    console.log
      Validation Summary:

      errors          1
      notices         0
      warnings        0

      ERRORS:

      Code                    Message       Description              File   Line   Column
      TYPE_NO_MANIFEST_JSON   manifest.j…   No manifest.json was
                              son was not   found at the root of
                              found         the extension. The
                                            package file must be a
                                            ZIP of the extension's
                                            files themselves, not
                                            of the containing
                                            directory. See:
                                            https://mzl.la/2r2McKv
                                            for more on packaging.

      at Linter.log [as print] (src/linter.js:152:16)

    console.log
      {"hasErrors":true,"metadata":{"totalScannedFileSize":0,"emptyFiles":[],"jsLibs":{},"unknownMinifiedFiles":[]},"errors":[{"_type":"error","code":"TYPE_NO_MANIFEST_JSON","message":"manifest.json was not found","description":"No manifest.json was found at the root of the extension. The package file must be a ZIP of the extension's files themselves, not of the containing directory. See: https://mzl.la/2r2McKv for more on packaging."}]}

      at Linter.log [as extractMetadata] (src/linter.js:530:16)

    console.log
      {"hasErrors":true,"metadata":{"totalScannedFileSize":0,"emptyFiles":[],"jsLibs":{},"unknownMinifiedFiles":[]},"errors":[{"_type":"error","code":"TYPE_NO_MANIFEST_JSON","message":"manifest.json was not found","description":"No manifest.json was found at the root of the extension. The package file must be a ZIP of the extension's files themselves, not of the containing directory. See: https://mzl.la/2r2McKv for more on packaging."}]}

      at Linter.log [as extractMetadata] (src/linter.js:530:16)

    console.error
      Selected file(s) not found: subdir/test.js

      135 |       _console.error(err.stack);
      136 |     } else {
    > 137 |       _console.error(this.chalk.red(err.message || err));
          |                ^
      138 |     }
      139 |
      140 |     this.closeIO();

      at Linter.error [as handleError] (src/linter.js:137:16)
      at Linter.handleError [as scan] (src/linter.js:593:16)
      at Linter.run (src/linter.js:626:5)
      at Object.<anonymous> (tests/unit/test.linter.js:1750:7)

    console.error
      Selected file(s) not found: subdir/test.js

      135 |       _console.error(err.stack);
      136 |     } else {
    > 137 |       _console.error(this.chalk.red(err.message || err));
          |                ^
      138 |     }
      139 |
      140 |     this.closeIO();

      at Linter.error [as handleError] (src/linter.js:137:16)
      at Linter.handleError [as scan] (src/linter.js:593:16)
      at Linter.run (src/linter.js:626:5)
      at Object.<anonymous> (tests/unit/test.linter.js:1764:7)

    console.log
      Validation Summary:

      errors          1
      notices         0
      warnings        0

      ERRORS:

      Code                    Message       Description              File   Line   Column
      TYPE_NO_MANIFEST_JSON   manifest.j…   No manifest.json was
                              son was not   found at the root of
                              found         the extension. The
                                            package file must be a
                                            ZIP of the extension's
                                            files themselves, not
                                            of the containing
                                            directory. See:
                                            https://mzl.la/2r2McKv
                                            for more on packaging.

      at Linter.log [as print] (src/linter.js:152:16)

  ● Linter › should scan mjs files

    AssertError: expected spy, spy to be called in order but were called as spy, spy

      214 |
      215 |     await addonLinter.scan();
    > 216 |     sinon.assert.callOrder(
          |                  ^
      217 |       getFileSpy.withArgs(filename),
      218 |       getFileSpy.withArgs('manifest.json')
      219 |     );

      at Object.fail (node_modules/sinon/lib/sinon/assert.js:60:27)
      at failAssertion (node_modules/sinon/lib/sinon/assert.js:203:20)
      at Object.assertCallOrder [as callOrder] (node_modules/sinon/lib/sinon/assert.js:90:17)
      at callOrder (tests/unit/test.linter.js:216:18)

  ● Linter.extractMetadata() › should flag known JS libraries

    expect(received).toEqual(expected) // deep equality

    Expected: 1
    Received: 0

      1142 |     });
      1143 |     sinon.assert.calledOnce(markJSFilesSpy);
    > 1144 |     expect(Object.keys(metadata.jsLibs).length).toEqual(1);
           |                                                 ^
      1145 |     expect(metadata.jsLibs).toEqual({
      1146 |       'my/nested/library/path/j.js': 'jquery.3.2.1.jquery.min.js',
      1147 |     });

      at Object.toEqual (tests/unit/test.linter.js:1144:49)

  ● Linter.extractMetadata() › should flag potentially minified JS files

    expect(received).toEqual(expected) // deep equality

    - Expected  - 1
    + Received  + 0

      Array [
    -   "modified-jquery.js",
        "modified-angular.js",
        "minified-with-sourcemap.js",
        "sourcemap-with-external-url.js",
        "minified-no-nl.js",
      ]

      1315 |     });
      1316 |     sinon.assert.calledOnce(markUnknownOrMinifiedCodeSpy);
    > 1317 |     expect(metadata.unknownMinifiedFiles).toEqual([
           |                                           ^
      1318 |       'modified-jquery.js',
      1319 |       'modified-angular.js',
      1320 |       'minified-with-sourcemap.js',

      at Object.toEqual (tests/unit/test.linter.js:1317:43)

 PASS  tests/unit/scanners/test.javascript.js
 PASS  tests/unit/schema/test.manifest_version.js
 PASS  tests/unit/test.main.js
 PASS  tests/unit/rules/javascript/test.no_unsafe_innerhtml.js
 PASS  tests/unit/scripts/test.dispensary.js
 PASS  tests/unit/scanners/test.langpack.js
 PASS  tests/unit/rules/javascript/test.unsupported_browser_api.js
 PASS  tests/unit/test.cli-process.js
 PASS  tests/unit/rules/javascript/test.content_scripts_file_absent.js
 PASS  tests/unit/scanners/test.json.js
 PASS  tests/unit/rules/javascript/test.deprecated_browser_apis.js
 PASS  tests/unit/rules/javascript/test.incompatible_browser_api.js
 PASS  tests/unit/parsers/test.locale-messagesjson.js
 PASS  tests/unit/rules/javascript/test.unsupported_mv2_browser_api.js
 PASS  tests/unit/parsers/test.doctype.js
 PASS  tests/unit/rules/javascript/test.no_implied_eval.js
 PASS  tests/unit/rules/javascript/test.no_eval.js
 PASS  tests/unit/rules/javascript/test.no_document_write.js
 PASS  tests/unit/rules/javascript/test.no_new_func.js
 PASS  tests/unit/rules/javascript/test.opendialog_nonlit_uri.js
 PASS  tests/unit/parsers/test.json.js
 PASS  tests/unit/parsers/test.fluent.js
 PASS  tests/unit/schema/test.web_accessible_resources.js
 PASS  tests/unit/schema/test.action.js
 PASS  tests/unit/parsers/test.properties.js
 PASS  tests/unit/rules/javascript/test.opendialog_remote_uri.js
 PASS  tests/unit/rules/javascript/test.widget_module.js
 PASS  tests/unit/rules/javascript/test.eslintRulesObject.js
 PASS  tests/unit/schema/test.schema.js
 PASS  tests/unit/scanners/test.html.js
 PASS  tests/unit/test.utils.js
 PASS  tests/unit/schema/test.static_theme.js
 PASS  tests/unit/schema/test.permissions.js
 PASS  tests/unit/schema/test.langpack.js
 PASS  tests/unit/schema/test.experiments.js
 PASS  tests/unit/schema/test.developer.js
 PASS  tests/unit/schema/test.commands.js
 PASS  tests/unit/schema/test.privileged.js
 PASS  tests/unit/schema/test.content_scripts.js
 PASS  tests/unit/schema/test.homepage_url.js
 PASS  tests/unit/schema/test.browser_specific_settings.js
 PASS  tests/unit/schema/test.name.js
 PASS  tests/unit/schema/test.declarative_net_request.js
 PASS  tests/unit/schema/test.author.js
 PASS  tests/unit/schema/test.incognito.js
 PASS  tests/unit/schema/test.background.js
 PASS  tests/unit/schema/test.icons.js
 PASS  tests/unit/test.messages.js
 PASS  tests/unit/scanners/test.filename.js
 PASS  tests/unit/scanners/test.base.js
 PASS  tests/unit/scanners/test.binary.js
 PASS  tests/unit/schema/test.locale-messagesjson.js
 PASS  tests/unit/test.cli.js
 PASS  tests/unit/schema/test.browser-apis.js
 PASS  tests/unit/test.collector.js
 PASS  tests/unit/schema/test.formats.js
 PASS  tests/unit/test.message.js
 PASS  tests/unit/dispensary/test.utils.js
 PASS  tests/unit/test.logger.js
 PASS  tests/unit/dispensary/test.hasher.js
 PASS  tests/unit/schema/test.deepmerge.js
 PASS  tests/unit/dispensary/test.index.js
 PASS  tests/test.yargs-options.js
 FAIL  tests/unit/schema/test.firefox-schemas-import.js
  ● Test suite failed to run

    TypeError: pending is not a function

      58 |   if (process.platform === 'win32') {
      59 |     // eslint-disable-next-line jest/no-disabled-tests
    > 60 |     pending();
         |     ^
      61 |     return;
      62 |   }
      63 |

      at pending (tests/unit/schema/test.firefox-schemas-import.js:60:5)
      at Object.describe (tests/unit/schema/test.firefox-schemas-import.js:56:1)

Summary of all failing tests
 FAIL  tests/unit/parsers/test.manifestjson.js
  ● ManifestJSONParser › locales › emits an error when messages.json is missing in language directory

    expect(received).toEqual(expected) // deep equality

    - Expected  - 2
    + Received  + 8

    - ObjectContaining {
    + Message {
    +   "_type": "error",
        "code": "NO_MESSAGES_FILE_IN_LOCALES",
    -   "description": StringMatching /file missing in "_locales\/hi"/,
    +   "column": undefined,
    +   "description": "messages.json file missing in \"_locales\\hi\"",
    +   "file": "manifest.json",
    +   "instancePath": undefined,
    +   "line": undefined,
    +   "message": "Empty language directory",
      }

      4129 |       const { errors } = addonLinter.collector;
      4130 |       expect(errors.length).toEqual(3);
    > 4131 |       expect(errors[0]).toEqual(
           |                         ^
      4132 |         expect.objectContaining({
      4133 |           code: messages.NO_MESSAGES_FILE_IN_LOCALES,
      4134 |           description: expect.stringMatching(`file missing in "_locales/hi"`),

      at Object.toEqual (tests/unit/parsers/test.manifestjson.js:4131:25)

 FAIL  tests/unit/test.linter.js
  ● Linter › should scan mjs files

    AssertError: expected spy, spy to be called in order but were called as spy, spy

      214 |
      215 |     await addonLinter.scan();
    > 216 |     sinon.assert.callOrder(
          |                  ^
      217 |       getFileSpy.withArgs(filename),
      218 |       getFileSpy.withArgs('manifest.json')
      219 |     );

      at Object.fail (node_modules/sinon/lib/sinon/assert.js:60:27)
      at failAssertion (node_modules/sinon/lib/sinon/assert.js:203:20)
      at Object.assertCallOrder [as callOrder] (node_modules/sinon/lib/sinon/assert.js:90:17)
      at callOrder (tests/unit/test.linter.js:216:18)

  ● Linter.extractMetadata() › should flag known JS libraries

    expect(received).toEqual(expected) // deep equality

    Expected: 1
    Received: 0

      1142 |     });
      1143 |     sinon.assert.calledOnce(markJSFilesSpy);
    > 1144 |     expect(Object.keys(metadata.jsLibs).length).toEqual(1);
           |                                                 ^
      1145 |     expect(metadata.jsLibs).toEqual({
      1146 |       'my/nested/library/path/j.js': 'jquery.3.2.1.jquery.min.js',
      1147 |     });

      at Object.toEqual (tests/unit/test.linter.js:1144:49)

  ● Linter.extractMetadata() › should flag potentially minified JS files

    expect(received).toEqual(expected) // deep equality

    - Expected  - 1
    + Received  + 0

      Array [
    -   "modified-jquery.js",
        "modified-angular.js",
        "minified-with-sourcemap.js",
        "sourcemap-with-external-url.js",
        "minified-no-nl.js",
      ]

      1315 |     });
      1316 |     sinon.assert.calledOnce(markUnknownOrMinifiedCodeSpy);
    > 1317 |     expect(metadata.unknownMinifiedFiles).toEqual([
           |                                           ^
      1318 |       'modified-jquery.js',
      1319 |       'modified-angular.js',
      1320 |       'minified-with-sourcemap.js',

      at Object.toEqual (tests/unit/test.linter.js:1317:43)

 FAIL  tests/unit/schema/test.firefox-schemas-import.js
  ● Test suite failed to run

    TypeError: pending is not a function

      58 |   if (process.platform === 'win32') {
      59 |     // eslint-disable-next-line jest/no-disabled-tests
    > 60 |     pending();
         |     ^
      61 |     return;
      62 |   }
      63 |

      at pending (tests/unit/schema/test.firefox-schemas-import.js:60:5)
      at Object.describe (tests/unit/schema/test.firefox-schemas-import.js:56:1)


Test Suites: 3 failed, 63 passed, 66 total
Tests:       4 failed, 1 skipped, 1576 passed, 1581 total
Snapshots:   0 total
Time:        17.246 s
Ran all test suites.

What did you expect to happen?

All tests should pass

┆Issue is synchronized with this Jira Task

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