Skip to content

Commit e2f9706

Browse files
filipesilvaalexeagle
authored andcommitted
Use jasmine test in rollup
1 parent 7eb9bea commit e2f9706

6 files changed

Lines changed: 94 additions & 48 deletions

File tree

‎examples/rollup/BUILD.bazel‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# NOTE: the example uses //:defs.bzl because it lives in the same WORKSPACE
22
# as the rule declarations.
33
# Users should use @build_bazel_rules_nodejs//:defs.bzl
4-
load("//:defs.bzl", "nodejs_binary")
4+
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
5+
load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
56

67
filegroup(
78
name = "node_modules",
@@ -23,8 +24,9 @@ rollup(
2324
srcs = ["foo.js", "bar.js"],
2425
)
2526

26-
sh_test(
27+
jasmine_node_test(
2728
name = "test",
28-
srcs = ["test.sh"],
29-
data = [":bundle.js"],
29+
srcs = glob(["*.spec.js"]),
30+
deps = [":bundle"],
31+
node_modules = ":node_modules",
3032
)

‎examples/rollup/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"devDependencies": {
3+
"jasmine": "~2.8.0",
34
"rollup": "~0.48.2"
45
}
56
}

‎examples/rollup/rollup.spec.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const fs = require('fs');
2+
3+
describe('bundling', () => {
4+
it('should work', () => {
5+
const actual = fs.readFileSync(require.resolve('./bundle.js'), { encoding: 'utf-8' });
6+
const expected = 'const name = \'Alice\';\n\nconsole.log(`Hello, ${name}`);\n';
7+
expect(actual).toEqual(expected);
8+
});
9+
});

‎examples/rollup/test.sh‎

Lines changed: 0 additions & 44 deletions
This file was deleted.

‎examples/rollup/yarn.lock‎

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,83 @@
22
# yarn lockfile v1
33

44

5+
balanced-match@^1.0.0:
6+
version "1.0.0"
7+
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
8+
9+
brace-expansion@^1.1.7:
10+
version "1.1.8"
11+
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292"
12+
dependencies:
13+
balanced-match "^1.0.0"
14+
concat-map "0.0.1"
15+
16+
concat-map@0.0.1:
17+
version "0.0.1"
18+
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
19+
20+
exit@^0.1.2:
21+
version "0.1.2"
22+
resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c"
23+
24+
fs.realpath@^1.0.0:
25+
version "1.0.0"
26+
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
27+
28+
glob@^7.0.6:
29+
version "7.1.2"
30+
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
31+
dependencies:
32+
fs.realpath "^1.0.0"
33+
inflight "^1.0.4"
34+
inherits "2"
35+
minimatch "^3.0.4"
36+
once "^1.3.0"
37+
path-is-absolute "^1.0.0"
38+
39+
inflight@^1.0.4:
40+
version "1.0.6"
41+
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
42+
dependencies:
43+
once "^1.3.0"
44+
wrappy "1"
45+
46+
inherits@2:
47+
version "2.0.3"
48+
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
49+
50+
jasmine-core@~2.8.0:
51+
version "2.8.0"
52+
resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-2.8.0.tgz#bcc979ae1f9fd05701e45e52e65d3a5d63f1a24e"
53+
54+
jasmine@~2.8.0:
55+
version "2.8.0"
56+
resolved "https://registry.yarnpkg.com/jasmine/-/jasmine-2.8.0.tgz#6b089c0a11576b1f16df11b80146d91d4e8b8a3e"
57+
dependencies:
58+
exit "^0.1.2"
59+
glob "^7.0.6"
60+
jasmine-core "~2.8.0"
61+
62+
minimatch@^3.0.4:
63+
version "3.0.4"
64+
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
65+
dependencies:
66+
brace-expansion "^1.1.7"
67+
68+
once@^1.3.0:
69+
version "1.4.0"
70+
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
71+
dependencies:
72+
wrappy "1"
73+
74+
path-is-absolute@^1.0.0:
75+
version "1.0.1"
76+
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
77+
578
rollup@~0.48.2:
679
version "0.48.2"
780
resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.48.2.tgz#dd9214eaf78d98a7771bf5583123cc80a0b5d6dc"
81+
82+
wrappy@1:
83+
version "1.0.2"
84+
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"

‎internal/node_loader.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ module.constructor._resolveFilename =
107107
var resolveLocations = [
108108
request,
109109
resolveRunfiles(request),
110+
resolveRunfiles('TEMPLATED_workspace_name', 'TEMPLATED_label_package', request),
110111
resolveRunfiles(
111112
'TEMPLATED_workspace_name', 'TEMPLATED_label_package',
112113
'node_modules', request),

0 commit comments

Comments
 (0)