generated from bazel-contrib/rules-template
-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b80b99
commit a486b66
Showing
19 changed files
with
152 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
e2e/ | ||
node_modules | ||
example/node_modules | ||
jest/tests/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"private": true, | ||
"dependencies": { | ||
"react": "18.2.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "7.20.2", | ||
"@babel/preset-env": "7.20.2", | ||
"@babel/preset-react": "7.18.6", | ||
"@jest/test-sequencer": "29.3.1", | ||
"babel-jest": "29.3.1", | ||
"jest-junit": "15.0.0", | ||
"react-test-renderer": "18.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
load("@aspect_rules_js//js:defs.bzl", "js_library") | ||
load("@bazel_skylib//rules:build_test.bzl", "build_test") | ||
load("//jest:defs.bzl", "jest_test") | ||
|
||
jest_test( | ||
name = "test", | ||
config = "jest.config.js", | ||
data = [ | ||
"babel.config.cjs", | ||
"package.json", | ||
":lib", | ||
":tests", | ||
"//jest/tests:node_modules/@babel/core", | ||
"//jest/tests:node_modules/@babel/preset-env", | ||
"//jest/tests:node_modules/@babel/preset-react", | ||
"//jest/tests:node_modules/babel-jest", | ||
], | ||
snapshots = True, | ||
) | ||
|
||
# Tests are normally in their own targets. | ||
js_library( | ||
name = "tests", | ||
testonly = True, | ||
srcs = [ | ||
"greetings.test.js", | ||
"link.test.js", | ||
"simple.test.js", | ||
], | ||
deps = [ | ||
"//jest/tests:node_modules/react-test-renderer", | ||
], | ||
) | ||
|
||
js_library( | ||
name = "lib", | ||
srcs = [ | ||
"greetings.js", | ||
"link.js", | ||
], | ||
deps = [ | ||
"//jest/tests:node_modules/react", | ||
], | ||
) | ||
|
||
# TEST: Ensure the {name}_update_snapshots target builds successfully | ||
build_test( | ||
name = "update_snapshots_build", | ||
targets = [":test_update_snapshots"], | ||
) |
Empty file.
9 changes: 9 additions & 0 deletions
9
jest/tests/package_json_module/__snapshots__/greetings.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`renders correctly 1`] = ` | ||
<h2> | ||
Hello | ||
World | ||
! | ||
</h2> | ||
`; |
9 changes: 9 additions & 0 deletions
9
jest/tests/package_json_module/__snapshots__/link.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`renders correctly 1`] = ` | ||
<a | ||
href="https://aspect.build" | ||
> | ||
Aspect | ||
</a> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
presets: [ | ||
"@babel/preset-env", | ||
["@babel/preset-react", { runtime: "automatic" }], | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Greetings(props) { | ||
return <h2>Hello {props.name}!</h2>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import renderer from "react-test-renderer"; | ||
import Greetings from "./greetings"; | ||
|
||
it("renders correctly", () => { | ||
const tree = renderer.create(<Greetings name="World" />).toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export default { | ||
testEnvironment: "node", | ||
testMatch: ["**/*.test.js"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Link({ page, children }) { | ||
return <a href={page || "#"}>{children}</a>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import renderer from "react-test-renderer"; | ||
import Link from "./link"; | ||
|
||
it("renders correctly", () => { | ||
const tree = renderer | ||
.create(<Link page="https://aspect.build">Aspect</Link>) | ||
.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"type": "module" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test("2+2==4", () => { | ||
expect(2 + 2).toEqual(4); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
packages: | ||
- "example" | ||
- "jest/tests" |