Skip to content

Commit

Permalink
test(builtin): add test for issue 1813
Browse files Browse the repository at this point in the history
Issue bazel-contrib#1813 was fixed by bazel-contrib#1800 which is already landed. bazel-contrib#1805 also fixes via a different mechanism and will also land soon.
  • Loading branch information
gregmagolan committed Apr 9, 2020
1 parent a19eb2b commit 3790d1c
Show file tree
Hide file tree
Showing 6 changed files with 1,933 additions and 17 deletions.
21 changes: 21 additions & 0 deletions internal/linker/test/issue_1813/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
load("@npm//jest-cli:index.bzl", "jest_test")

jest_test(
name = "test",
data = [
"index.test.js",
"jest.config.js",
"@npm//jest",
"@npm//jest-websocket-mock",
"@npm//mock-socket",
],
templated_args = [
"--no-cache",
"--no-watchman",
"--ci",
# On Windows, spawing workers is broken
"--runInBand",
"--config",
"$$(rlocation $(rootpath jest.config.js))",
],
)
44 changes: 44 additions & 0 deletions internal/linker/test/issue_1813/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Loaded from common-js format
// node_modules/jest-websocket-mock/lib/jest-websocket-mock.cjs.js
const WS = require('jest-websocket-mock').default;
// Loaded from js format
// node_modules/mock-socket/dist/mock-socket.js"
const Server = require('mock-socket').Server;

// Fails without node-patches symlink guards fix in
// https://github.com/bazelbuild/rules_nodejs/pull/1800
// and node_modules execroot fix in
// https://github.com/bazelbuild/rules_nodejs/pull/1805:
// ```
// ==================== Test output for //internal/linker/test/issue_1813:test:
// FAIL internal/linker/test/issue_1813/index.test.js
// ✕ jest-websocket-mock (12ms)
//
// ● jest-websocket-mock
//
// expect(received).toBeInstanceOf(expected)
//
// Expected constructor: Server
// Received constructor: Server
//
// 12 | test('jest-websocket-mock', () => {
// 13 | const ws = new WS('ws://localhost:1234');
// > 14 | expect(ws.server).toBeInstanceOf(Server);
// | ^
// 15 | });
// 16 |
//
// at Object.<anonymous> (index.test.js:14:21)
//
// Test Suites: 1 failed, 1 total
// Tests: 1 failed, 1 total
// Snapshots: 0 total
// Time: 1.453s
// Ran all test suites.
// ================================================================================
// ```
// See https://github.com/bazelbuild/rules_nodejs/issues/1813
test('jest-websocket-mock', () => {
const ws = new WS('ws://localhost:1234');
expect(ws.server).toBeInstanceOf(Server);
});
4 changes: 4 additions & 0 deletions internal/linker/test/issue_1813/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
testEnvironment: 'node',
testMatch: ['**/*.test.js'],
};
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
"jasmine": "~3.4.0",
"jasmine-core": "~3.4.0",
"jasmine-reporters": "~2.3.2",
"jest": "~25.3.0",
"jest-websocket-mock": "~2.0.2",
"karma": "~4.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-firefox-launcher": "1.1.0",
Expand All @@ -51,6 +53,7 @@
"karma-sourcemap-loader": "0.3.7",
"lit-element": "^2.2.1",
"minimist": "^1.2.2",
"mock-socket": "~9.0.3",
"node_resolve_index": "file:./tools/npm_packages/node_resolve_index",
"node_resolve_index_2": "file:./tools/npm_packages/node_resolve_index_2",
"node_resolve_index_3": "file:./tools/npm_packages/node_resolve_index_3",
Expand All @@ -59,6 +62,7 @@
"node_resolve_main_2": "file:./tools/npm_packages/node_resolve_main_2",
"node_resolve_nested_main": "file:./tools/npm_packages/node_resolve_nested_main",
"npm": "6.13.7",
"patch-package": "^6.2.2",
"protobufjs": "6.8.8",
"protractor": "^5.4.2",
"requirejs": "2.3.6",
Expand Down Expand Up @@ -86,6 +90,10 @@
"yarn": "1.22.0",
"zone.js": "0.8.29"
},
"// resolutions/**/jest-serializer": "need to resolve to a version that doesn't have a /// <reference path='../v8.d.ts' /> in build/index.d.ts which exposes a bug in ts_library",
"resolutions": {
"**/jest-serializer": "24.3.0"
},
"scripts": {
"test": "bazelisk test --test_tag_filters=-e2e,-examples,-manual,-browser:firefox-local",
"test_windows": "bazelisk test --test_tag_filters=-e2e,-examples,-fix-windows,-manual,-browser:firefox-local",
Expand Down Expand Up @@ -115,7 +123,7 @@
"format-all": "clang-format --glob='{internal/**/,examples/**/}*.{js,ts}' -i",
"stardoc": "bazelisk build //docs && cp -f dist/bin/docs/*.md docs",
"version": "conventional-changelog -p angular -i CHANGELOG.md -s && node ./scripts/on-version.js && bazel build //:release && node ./scripts/on-release.js && git stage version.bzl docs/install.md packages/create/index.js README.md CHANGELOG.md e2e/*/WORKSPACE examples/*/WORKSPACE",
"postinstall": "node internal/npm_install/test/postinstall.js"
"postinstall": "patch-package && node internal/npm_install/test/postinstall.js"
},
"husky": {
"hooks": {
Expand Down
16 changes: 16 additions & 0 deletions patches/jest-haste-map+25.3.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/node_modules/jest-haste-map/build/crawlers/node.js b/node_modules/jest-haste-map/build/crawlers/node.js
index 349c3bd..08ba33b 100644
--- a/node_modules/jest-haste-map/build/crawlers/node.js
+++ b/node_modules/jest-haste-map/build/crawlers/node.js
@@ -205,7 +205,11 @@ function find(roots, extensions, ignore, callback) {

function findNative(roots, extensions, ignore, callback) {
const args = Array.from(roots);
+ args.push('(');
args.push('-type', 'f');
+ args.push('-o');
+ args.push('-type', 'l');
+ args.push(')');

if (extensions.length) {
args.push('(');
Loading

0 comments on commit 3790d1c

Please sign in to comment.