diff --git a/common/BUILD.bazel b/common/BUILD.bazel index 7bcd334e..a8b98ea2 100644 --- a/common/BUILD.bazel +++ b/common/BUILD.bazel @@ -152,6 +152,7 @@ ts_project( "//common/models:prerender_annotation", "@npm//@types/jasmine", "@npm//node-html-parser", + "//:node_modules/node-html-parser", ], ) diff --git a/common/testing/BUILD.bazel b/common/testing/BUILD.bazel index 846c67c2..68f654d0 100644 --- a/common/testing/BUILD.bazel +++ b/common/testing/BUILD.bazel @@ -36,6 +36,8 @@ ts_project( ":effects", ":test_server", "//common:http", + "//:node_modules/http-status-codes", + "//:node_modules/tree-kill", "@npm//@types/jasmine", "@npm//@types/node", "@npm//http-status-codes", @@ -51,10 +53,10 @@ ts_project( ":devserver", ":effect_tester", "//common:http", - "@npm//@bazel/runfiles", "@npm//@types/jasmine", "@npm//@types/node", "@npm//http-status-codes", + "//:node_modules/http-status-codes", ], ) @@ -229,6 +231,8 @@ ts_project( ":test_server", "@npm//@types/node", "@npm//webdriverio", + "//:node_modules/debug", # TODO(#48): Remove after WebDriver supports pnpm. + "//:node_modules/webdriverio", ], ) @@ -240,7 +244,6 @@ ts_project( ":devserver", ":webdriver", "effect_tester", - "@npm//@bazel/runfiles", "@npm//@types/jasmine", "@npm//webdriverio", ], diff --git a/common/testing/devserver_test.ts b/common/testing/devserver_test.ts index 74e7db76..722bbac4 100644 --- a/common/testing/devserver_test.ts +++ b/common/testing/devserver_test.ts @@ -1,11 +1,10 @@ import { URL } from 'url'; import { StatusCodes } from 'http-status-codes'; -import { runfiles } from '@bazel/runfiles'; import * as http from '../http'; import { Server, useDevserver } from './devserver'; import { EffectTester } from './effect_tester'; -const devserver = runfiles.resolvePackageRelative('devserver_test_server'); +const devserver = 'common/testing/devserver_test_server'; describe('devserver', () => { describe('Server', () => { diff --git a/common/testing/webdriver_test.ts b/common/testing/webdriver_test.ts index 292a8ea5..599af19f 100644 --- a/common/testing/webdriver_test.ts +++ b/common/testing/webdriver_test.ts @@ -1,15 +1,11 @@ -import { runfiles } from '@bazel/runfiles'; import * as webdriverio from 'webdriverio'; import { useDevserver } from './devserver'; import { EffectTester } from './effect_tester'; import { useWebDriver, webDriverTestTimeout } from './webdriver'; -const devserverBinary = - runfiles.resolvePackageRelative('webdriver_test_server'); - describe('webdriver', () => { describe('useWebDriver()', () => { - const devserver = useDevserver(devserverBinary); + const devserver = useDevserver('common/testing/webdriver_test_server'); it('manages a WebDriver session without a server under test', async () => { const remoteSpy = spyOn(webdriverio, 'remote').and.callThrough(); diff --git a/examples/components/BUILD.bazel b/examples/components/BUILD.bazel index 747e6142..02160cb1 100644 --- a/examples/components/BUILD.bazel +++ b/examples/components/BUILD.bazel @@ -58,7 +58,6 @@ ts_project( deps = [ "//common/testing:devserver", "//common/testing:webdriver", - "@npm//@bazel/runfiles", "@npm//@types/jasmine", ], ) diff --git a/examples/components/test.ts b/examples/components/test.ts index b325895c..bce5fcd1 100644 --- a/examples/components/test.ts +++ b/examples/components/test.ts @@ -1,11 +1,8 @@ -import { runfiles } from '@bazel/runfiles'; import { useDevserver } from '../../common/testing/devserver'; import { useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver'; -const devserverBinary = runfiles.resolvePackageRelative('devserver'); - describe('components', () => { - const devserver = useDevserver(devserverBinary); + const devserver = useDevserver('examples/components/devserver'); const wd = useWebDriver(devserver); it('renders', async () => { diff --git a/examples/custom_bundling/BUILD.bazel b/examples/custom_bundling/BUILD.bazel index 9e71984a..396a6b25 100644 --- a/examples/custom_bundling/BUILD.bazel +++ b/examples/custom_bundling/BUILD.bazel @@ -77,7 +77,6 @@ ts_project( deps = [ "//common/testing:devserver", "//common/testing:webdriver", - "@npm//@bazel/runfiles", "@npm//@types/jasmine", ], ) diff --git a/examples/custom_bundling/test.ts b/examples/custom_bundling/test.ts index ff451264..38096d2d 100644 --- a/examples/custom_bundling/test.ts +++ b/examples/custom_bundling/test.ts @@ -1,11 +1,8 @@ -import { runfiles } from '@bazel/runfiles'; import { useDevserver } from '../../common/testing/devserver'; import { useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver'; -const devserverBinary = runfiles.resolvePackageRelative('devserver'); - describe('custom bundling', () => { - const devserver = useDevserver(devserverBinary); + const devserver = useDevserver('examples/custom_bundling/devserver'); const wd = useWebDriver(devserver); it('renders a custom bundled page', async () => { diff --git a/examples/data/BUILD.bazel b/examples/data/BUILD.bazel index f1ccc959..1732ad2d 100644 --- a/examples/data/BUILD.bazel +++ b/examples/data/BUILD.bazel @@ -28,7 +28,6 @@ ts_project( deps = [ "//common/testing:devserver", "//common/testing:webdriver", - "@npm//@bazel/runfiles", "@npm//@types/jasmine", ], ) diff --git a/examples/data/test.ts b/examples/data/test.ts index 17a2e5af..aa6ce376 100644 --- a/examples/data/test.ts +++ b/examples/data/test.ts @@ -1,11 +1,8 @@ -import { runfiles } from '@bazel/runfiles'; import { useDevserver } from '../../common/testing/devserver'; import { useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver'; -const devserverBinary = runfiles.resolvePackageRelative('devserver'); - describe('data', () => { - const devserver = useDevserver(devserverBinary); + const devserver = useDevserver('examples/data/devserver'); const wd = useWebDriver(devserver); describe('index page', () => { diff --git a/examples/declarative_shadow_dom/BUILD.bazel b/examples/declarative_shadow_dom/BUILD.bazel index 562ec00a..015c8d09 100644 --- a/examples/declarative_shadow_dom/BUILD.bazel +++ b/examples/declarative_shadow_dom/BUILD.bazel @@ -45,7 +45,6 @@ ts_project( deps = [ "//common/testing:devserver", "//common/testing:webdriver", - "@npm//@bazel/runfiles", "@npm//@types/jasmine", ], ) diff --git a/examples/declarative_shadow_dom/test.ts b/examples/declarative_shadow_dom/test.ts index da56030d..83b200f0 100644 --- a/examples/declarative_shadow_dom/test.ts +++ b/examples/declarative_shadow_dom/test.ts @@ -1,11 +1,8 @@ -import { runfiles } from '@bazel/runfiles'; import { useDevserver } from '../../common/testing/devserver'; import { getColor, useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver'; -const devserverBinary = runfiles.resolvePackageRelative('devserver'); - describe('Declarative Shadow DOM', () => { - const devserver = useDevserver(devserverBinary); + const devserver = useDevserver('examples/declarative_shadow_dom/devserver'); const wd = useWebDriver(devserver); it('attaches the declarative shadow root to its host', async () => { diff --git a/examples/javascript/BUILD.bazel b/examples/javascript/BUILD.bazel index bd7a8065..171395df 100644 --- a/examples/javascript/BUILD.bazel +++ b/examples/javascript/BUILD.bazel @@ -21,7 +21,6 @@ ts_project( deps = [ "//common/testing:devserver", "//common/testing:webdriver", - "@npm//@bazel/runfiles", "@npm//@types/jasmine", ], ) diff --git a/examples/javascript/test.ts b/examples/javascript/test.ts index 9bd07cd9..01e1522c 100644 --- a/examples/javascript/test.ts +++ b/examples/javascript/test.ts @@ -1,11 +1,8 @@ -import { runfiles } from '@bazel/runfiles'; import { useDevserver } from '../../common/testing/devserver'; import { useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver'; -const devserverBinary = runfiles.resolvePackageRelative('devserver'); - describe('JavaScript', () => { - const devserver = useDevserver(devserverBinary); + const devserver = useDevserver('examples/javascript/devserver'); const wd = useWebDriver(devserver); it('renders component', async () => { diff --git a/examples/minimal/BUILD.bazel b/examples/minimal/BUILD.bazel index 7604921d..54eb1f14 100644 --- a/examples/minimal/BUILD.bazel +++ b/examples/minimal/BUILD.bazel @@ -38,7 +38,6 @@ ts_project( "//common/testing:devserver", "//common/testing:webdriver", "@npm//@types/jasmine", - "@npm//@bazel/runfiles", ], ) diff --git a/examples/minimal/test.ts b/examples/minimal/test.ts index ce9897c6..4db39a8c 100644 --- a/examples/minimal/test.ts +++ b/examples/minimal/test.ts @@ -1,11 +1,8 @@ -import { runfiles } from '@bazel/runfiles'; import { useDevserver } from '../../common/testing/devserver'; import { useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver'; -const devserverBinary = runfiles.resolvePackageRelative('devserver'); - describe('minimal', () => { - const devserver = useDevserver(devserverBinary); + const devserver = useDevserver('examples/minimal/devserver'); const wd = useWebDriver(devserver); it('renders', async () => { diff --git a/examples/multi_page/BUILD.bazel b/examples/multi_page/BUILD.bazel index 352f9da8..cc68ff8a 100644 --- a/examples/multi_page/BUILD.bazel +++ b/examples/multi_page/BUILD.bazel @@ -49,7 +49,6 @@ ts_project( deps = [ "//common/testing:devserver", "//common/testing:webdriver", - "@npm//@bazel/runfiles", "@npm//@types/jasmine", ], ) diff --git a/examples/multi_page/test.ts b/examples/multi_page/test.ts index 76c074bb..7771a59f 100644 --- a/examples/multi_page/test.ts +++ b/examples/multi_page/test.ts @@ -1,11 +1,8 @@ -import { runfiles } from '@bazel/runfiles'; import { useDevserver } from '../../common/testing/devserver'; import { getColor, useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver'; -const devserverBinary = runfiles.resolvePackageRelative('devserver'); - describe('multi_page', () => { - const devserver = useDevserver(devserverBinary); + const devserver = useDevserver('examples/multi_page/devserver'); const wd = useWebDriver(devserver); describe('index page', () => { diff --git a/examples/prerender_resources/BUILD.bazel b/examples/prerender_resources/BUILD.bazel index 7d7df3cf..1d809490 100644 --- a/examples/prerender_resources/BUILD.bazel +++ b/examples/prerender_resources/BUILD.bazel @@ -20,7 +20,6 @@ ts_project( testonly = True, data = [":prerender"], deps = [ - "@npm//@bazel/runfiles", "@npm//@types/jasmine", "@npm//@types/node", ], diff --git a/examples/prerender_resources/generator_test.ts b/examples/prerender_resources/generator_test.ts index 77d59a9b..cbcfdd15 100644 --- a/examples/prerender_resources/generator_test.ts +++ b/examples/prerender_resources/generator_test.ts @@ -1,7 +1,6 @@ import { promises as fs } from 'fs'; -import { runfiles } from '@bazel/runfiles'; -const prerenderedDir = runfiles.resolvePackageRelative('prerender'); +const prerenderedDir = 'examples/prerender_resources/prerender'; describe('Prerender Resources', () => { it('prerenders `hello.txt`', async () => { diff --git a/examples/resources/BUILD.bazel b/examples/resources/BUILD.bazel index 24369080..ab9d72cb 100644 --- a/examples/resources/BUILD.bazel +++ b/examples/resources/BUILD.bazel @@ -41,7 +41,6 @@ ts_project( deps = [ "//common/testing:devserver", "//common/testing:webdriver", - "@npm//@bazel/runfiles", "@npm//@types/jasmine", ], ) diff --git a/examples/resources/test.ts b/examples/resources/test.ts index 3c4169ab..a3187d3e 100644 --- a/examples/resources/test.ts +++ b/examples/resources/test.ts @@ -1,11 +1,8 @@ -import { runfiles } from '@bazel/runfiles'; import { useDevserver } from '../../common/testing/devserver'; import { useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver'; -const devserverBinary = runfiles.resolvePackageRelative('devserver'); - describe('resources', () => { - const devserver = useDevserver(devserverBinary); + const devserver = useDevserver('examples/resources/devserver'); const wd = useWebDriver(devserver); it('renders with resources', async () => { diff --git a/examples/scripts/BUILD.bazel b/examples/scripts/BUILD.bazel index d9bfd029..d5d5e245 100644 --- a/examples/scripts/BUILD.bazel +++ b/examples/scripts/BUILD.bazel @@ -30,7 +30,6 @@ ts_project( deps = [ "//common/testing:devserver", "//common/testing:webdriver", - "@npm//@bazel/runfiles", "@npm//@types/jasmine", ], ) diff --git a/examples/scripts/test.ts b/examples/scripts/test.ts index a9ab5953..578f3de6 100644 --- a/examples/scripts/test.ts +++ b/examples/scripts/test.ts @@ -1,11 +1,8 @@ -import { runfiles } from '@bazel/runfiles'; import { useDevserver } from '../../common/testing/devserver'; import { useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver'; -const devserverBinary = runfiles.resolvePackageRelative('devserver'); - describe('Scripts', () => { - const devserver = useDevserver(devserverBinary); + const devserver = useDevserver('examples/scripts/devserver'); const wd = useWebDriver(devserver); it('renders with scripts', async () => { diff --git a/examples/site/blog/BUILD.bazel b/examples/site/blog/BUILD.bazel index c62bbc1c..ec95b746 100644 --- a/examples/site/blog/BUILD.bazel +++ b/examples/site/blog/BUILD.bazel @@ -12,6 +12,7 @@ prerender_pages( lib_deps = [ "//packages/rules_prerender", "//examples/site/common:links", + "//:node_modules/markdown-it", "@npm//markdown-it", "@npm//@types/markdown-it", "@npm//@types/node", @@ -30,10 +31,13 @@ ts_project( ":blog_prerender_for_test", "@npm//@types/jasmine", "@npm//node-html-parser", + "//:node_modules/node-html-parser", ], ) jasmine_node_test( name = "blog_test", + # TODO(#48): Turn on after declarative shadow DOM can be used in `@aspect_rules_js`. + tags = ["manual"], deps = [":blog_test_lib"], ) diff --git a/examples/site/components/base/BUILD.bazel b/examples/site/components/base/BUILD.bazel index 16f27639..77957670 100644 --- a/examples/site/components/base/BUILD.bazel +++ b/examples/site/components/base/BUILD.bazel @@ -7,7 +7,10 @@ prerender_component( srcs = ["base.ts"], tsconfig = "//:tsconfig.json", source_map = True, - lib_deps = ["//packages/rules_prerender"], + lib_deps = [ + "//packages/rules_prerender", + "//:node_modules/rules_prerender", + ], styles = [":styles"], visibility = ["//examples/site:__subpackages__"], deps = [ @@ -30,6 +33,7 @@ ts_project( ":base_prerender_for_test", "@npm//@types/jasmine", "@npm//node-html-parser", + "//:node_modules/node-html-parser", ], ) diff --git a/examples/site/components/counter/BUILD.bazel b/examples/site/components/counter/BUILD.bazel index af1e6631..d3c5ca83 100644 --- a/examples/site/components/counter/BUILD.bazel +++ b/examples/site/components/counter/BUILD.bazel @@ -12,7 +12,10 @@ prerender_component( srcs = ["counter_prerender.ts"], tsconfig = "//:tsconfig.json", source_map = True, - lib_deps = ["//packages/rules_prerender"], + lib_deps = [ + "//packages/rules_prerender", + "//:node_modules/rules_prerender", + ], scripts = [":scripts"], visibility = ["//examples/site:__subpackages__"], ) @@ -31,6 +34,7 @@ ts_project( ":counter_prerender_for_test", "@npm//@types/jasmine", "@npm//node-html-parser", + "//:node_modules/node-html-parser", ], ) @@ -62,7 +66,6 @@ ts_project( deps = [ "//common/testing:devserver", "//common/testing:webdriver", - "@npm//@bazel/runfiles", "@npm//@types/jasmine", ], ) diff --git a/examples/site/components/counter/counter_test.ts b/examples/site/components/counter/counter_test.ts index e8659e8c..6ed7d43a 100644 --- a/examples/site/components/counter/counter_test.ts +++ b/examples/site/components/counter/counter_test.ts @@ -1,12 +1,9 @@ -import { runfiles } from '@bazel/runfiles'; import { useDevserver } from '../../../../common/testing/devserver'; import { useWebDriver, webDriverTestTimeout } from '../../../../common/testing/webdriver'; -const devserverBinary = - runfiles.resolvePackageRelative('counter_test_cases_devserver'); - describe('Counter', () => { - const devserver = useDevserver(devserverBinary); + const devserver = useDevserver( + 'examples/site/components/counter/counter_test_cases_devserver'); const wd = useWebDriver(devserver); it('increments when the increment button is clicked', async () => { diff --git a/examples/site/components/footer/BUILD.bazel b/examples/site/components/footer/BUILD.bazel index 7682095f..6ba85aa5 100644 --- a/examples/site/components/footer/BUILD.bazel +++ b/examples/site/components/footer/BUILD.bazel @@ -10,6 +10,7 @@ prerender_component( lib_deps = [ "//examples/site/common:links", "//packages/rules_prerender", + "//:node_modules/rules_prerender", ], styles = [":styles"], visibility = ["//examples/site:__subpackages__"], @@ -29,6 +30,7 @@ ts_project( ":footer_prerender_for_test", "@npm//@types/jasmine", "@npm//node-html-parser", + "//:node_modules/node-html-parser", ], ) diff --git a/examples/site/components/header/BUILD.bazel b/examples/site/components/header/BUILD.bazel index f7034a86..b7f3cb87 100644 --- a/examples/site/components/header/BUILD.bazel +++ b/examples/site/components/header/BUILD.bazel @@ -7,7 +7,10 @@ prerender_component( srcs = ["header.ts"], tsconfig = "//:tsconfig.json", source_map = True, - lib_deps = ["//packages/rules_prerender"], + lib_deps = [ + "//packages/rules_prerender", + "//:node_modules/rules_prerender", + ], styles = [":styles"], visibility = ["//examples/site:__subpackages__"], ) @@ -26,6 +29,7 @@ ts_project( ":header_prerender_for_test", "@npm//@types/jasmine", "@npm//node-html-parser", + "//:node_modules/node-html-parser", ], ) diff --git a/examples/site/home/BUILD.bazel b/examples/site/home/BUILD.bazel index a1f8dc83..a70e9f73 100644 --- a/examples/site/home/BUILD.bazel +++ b/examples/site/home/BUILD.bazel @@ -31,7 +31,6 @@ ts_project( deps = [ "//common/testing:devserver", "//common/testing:webdriver", - "@npm//@bazel/runfiles", "@npm//@types/jasmine", ], ) diff --git a/examples/site/home/home_test.ts b/examples/site/home/home_test.ts index f0efc3bd..00fce5f5 100644 --- a/examples/site/home/home_test.ts +++ b/examples/site/home/home_test.ts @@ -1,11 +1,8 @@ -import { runfiles } from '@bazel/runfiles'; import { useDevserver } from '../../../common/testing/devserver'; import { useWebDriver, webDriverTestTimeout } from '../../../common/testing/webdriver'; -const devserverBinary = runfiles.resolvePackageRelative('home_devserver'); - describe('home', () => { - const devserver = useDevserver(devserverBinary); + const devserver = useDevserver('examples/site/home/home_devserver'); const wd = useWebDriver(devserver); it('renders the home page', async () => { diff --git a/examples/styles/BUILD.bazel b/examples/styles/BUILD.bazel index c09d4523..61220013 100644 --- a/examples/styles/BUILD.bazel +++ b/examples/styles/BUILD.bazel @@ -35,7 +35,6 @@ ts_project( deps = [ "//common/testing:devserver", "//common/testing:webdriver", - "@npm//@bazel/runfiles", "@npm//@types/jasmine", ], ) diff --git a/examples/styles/test.ts b/examples/styles/test.ts index 14ee7c59..b9aed7da 100644 --- a/examples/styles/test.ts +++ b/examples/styles/test.ts @@ -1,11 +1,8 @@ -import { runfiles } from '@bazel/runfiles'; import { useDevserver } from '../../common/testing/devserver'; import { getColor, useWebDriver } from '../../common/testing/webdriver'; -const devserverBinary = runfiles.resolvePackageRelative('devserver'); - describe('styles', () => { - const devserver = useDevserver(devserverBinary); + const devserver = useDevserver('examples/styles/devserver'); const wd = useWebDriver(devserver); it('renders inline styles', async () => { diff --git a/examples/tsjs/BUILD.bazel b/examples/tsjs/BUILD.bazel index 787abd4f..300b53a3 100644 --- a/examples/tsjs/BUILD.bazel +++ b/examples/tsjs/BUILD.bazel @@ -59,7 +59,6 @@ ts_project( deps = [ "//common/testing:devserver", "//common/testing:webdriver", - "@npm//@bazel/runfiles", "@npm//@types/jasmine", ], ) diff --git a/examples/tsjs/test.ts b/examples/tsjs/test.ts index a177a115..4e46fa80 100644 --- a/examples/tsjs/test.ts +++ b/examples/tsjs/test.ts @@ -1,11 +1,8 @@ -import { runfiles } from '@bazel/runfiles'; import { useDevserver } from '../../common/testing/devserver'; import { useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver'; -const devserverBinary = runfiles.resolvePackageRelative('devserver'); - describe('TS/JS', () => { - const devserver = useDevserver(devserverBinary); + const devserver = useDevserver('examples/tsjs/devserver'); const wd = useWebDriver(devserver); it('renders TypeScript depending on JavaScript', async () => { diff --git a/packages/annotation_extractor/BUILD.bazel b/packages/annotation_extractor/BUILD.bazel index 106eb800..74206287 100644 --- a/packages/annotation_extractor/BUILD.bazel +++ b/packages/annotation_extractor/BUILD.bazel @@ -38,7 +38,6 @@ ts_project( "//common/models:prerender_metadata_mock", "//common/testing:binary", "//common/testing:temp_dir", - "@npm//@bazel/runfiles", "@npm//@types/jasmine", "@npm//@types/node", ], @@ -56,7 +55,7 @@ ts_project( deps = [ "//common:prerender_annotation_walker", "//common/models:prerender_annotation", - "@npm//node-html-parser", + "//:node_modules/node-html-parser", ], ) diff --git a/packages/annotation_extractor/annotation_extractor_test.ts b/packages/annotation_extractor/annotation_extractor_test.ts index b16da9e4..d5ec57e3 100644 --- a/packages/annotation_extractor/annotation_extractor_test.ts +++ b/packages/annotation_extractor/annotation_extractor_test.ts @@ -1,12 +1,11 @@ import { promises as fs } from 'fs'; -import { runfiles } from '@bazel/runfiles'; import { mockPrerenderMetadata, mockScriptMetadata } from '../../common/models/prerender_metadata_mock'; import { PrerenderMetadata } from '../../common/models/prerender_metadata'; import { execBinary, ProcessResult } from '../../common/testing/binary'; import { useTempDir } from '../../common/testing/temp_dir'; import { createAnnotation } from '../../common/models/prerender_annotation'; -const extractor = runfiles.resolvePackageRelative('annotation_extractor.sh'); +const extractor = 'packages/annotation_extractor/annotation_extractor.sh'; async function run({ inputDir, outputHtmlDir, outputMetadata }: { inputDir: string, diff --git a/packages/renderer/BUILD.bazel b/packages/renderer/BUILD.bazel index ff872deb..aacdb725 100644 --- a/packages/renderer/BUILD.bazel +++ b/packages/renderer/BUILD.bazel @@ -49,7 +49,6 @@ ts_project( # Need a dependency on styles for entry points under test to import # `inlineStyle()`. "//packages/rules_prerender:styles", - "@npm//@bazel/runfiles", "@npm//@types/jasmine", "@npm//@types/node", ], diff --git a/packages/renderer/renderer_test.ts b/packages/renderer/renderer_test.ts index ce6deac1..3b0da9e2 100644 --- a/packages/renderer/renderer_test.ts +++ b/packages/renderer/renderer_test.ts @@ -1,10 +1,9 @@ import { promises as fs } from 'fs'; -import { runfiles } from '@bazel/runfiles'; import { execBinary, ProcessResult } from '../../common/testing/binary'; import { useTempDir } from '../../common/testing/temp_dir'; import { createAnnotation } from '../../common/models/prerender_annotation'; -const renderer = runfiles.resolvePackageRelative('renderer_test_binary.sh'); +const renderer = 'packages/renderer/renderer_test_binary.sh'; /** Invokes the renderer binary. */ async function run({ entryPoint, outputDir, inlineStyles = new Map() }: { diff --git a/packages/resource_injector/BUILD.bazel b/packages/resource_injector/BUILD.bazel index 9a945cde..04a9afcc 100644 --- a/packages/resource_injector/BUILD.bazel +++ b/packages/resource_injector/BUILD.bazel @@ -34,7 +34,6 @@ ts_project( ":config", "//common/testing:binary", "//common/testing:temp_dir", - "@npm//@bazel/runfiles", "@npm//@types/jasmine", "@npm//@types/node", ], @@ -58,7 +57,7 @@ ts_project( ":config", "//common:fs", "//common:prerender_annotation_walker", - "@npm//node-html-parser", + "//:node_modules/node-html-parser", ], ) diff --git a/packages/resource_injector/resource_injector_test.ts b/packages/resource_injector/resource_injector_test.ts index 35c5799f..45058a31 100644 --- a/packages/resource_injector/resource_injector_test.ts +++ b/packages/resource_injector/resource_injector_test.ts @@ -1,10 +1,9 @@ import { promises as fs } from 'fs'; -import { runfiles } from '@bazel/runfiles'; import { InjectorConfig } from './config'; import { execBinary, ProcessResult } from '../../common/testing/binary'; import { useTempDir } from '../../common/testing/temp_dir'; -const injector = runfiles.resolvePackageRelative('resource_injector.sh'); +const injector = 'packages/resource_injector/resource_injector.sh'; /** Invokes the resource injector binary. */ async function run({ inputDir, config, bundle, outputDir }: { diff --git a/packages/resource_packager/BUILD.bazel b/packages/resource_packager/BUILD.bazel index a540d2de..ef629a78 100644 --- a/packages/resource_packager/BUILD.bazel +++ b/packages/resource_packager/BUILD.bazel @@ -33,7 +33,6 @@ ts_project( deps = [ "//common/testing:binary", "//common/testing:temp_dir", - "@npm//@bazel/runfiles", "@npm//@types/jasmine", "@npm//@types/node", ], diff --git a/packages/resource_packager/resource_packager_test.ts b/packages/resource_packager/resource_packager_test.ts index 0127867c..4b2b6ff1 100644 --- a/packages/resource_packager/resource_packager_test.ts +++ b/packages/resource_packager/resource_packager_test.ts @@ -1,9 +1,8 @@ import { promises as fs } from 'fs'; -import { runfiles } from '@bazel/runfiles'; import { useTempDir } from '../../common/testing/temp_dir'; import { ProcessResult, execBinary } from '../../common/testing/binary'; -const binary = runfiles.resolvePackageRelative('resource_packager.sh'); +const binary = 'packages/resource_packager/resource_packager.sh'; async function run({ urlPaths, fileRefs, mergeDirs, destDir }: { urlPaths: string[], diff --git a/packages/rules_prerender/BUILD.bazel b/packages/rules_prerender/BUILD.bazel index 512a6693..93716013 100644 --- a/packages/rules_prerender/BUILD.bazel +++ b/packages/rules_prerender/BUILD.bazel @@ -102,7 +102,6 @@ ts_project( srcs = ["prerender_component_publish_files_test.ts"], data = ["//packages/rules_prerender/prerender_component_publish_files_testdata:component_publish_files"], deps = [ - "@npm//@bazel/runfiles", "@npm//@types/jasmine", "@npm//@types/node", ], diff --git a/packages/rules_prerender/prerender_component_publish_files_test.ts b/packages/rules_prerender/prerender_component_publish_files_test.ts index 30a5754c..46f46f19 100644 --- a/packages/rules_prerender/prerender_component_publish_files_test.ts +++ b/packages/rules_prerender/prerender_component_publish_files_test.ts @@ -1,8 +1,6 @@ -import { runfiles } from '@bazel/runfiles'; import { promises as fs } from 'fs'; -const root = runfiles.resolvePackageRelative( - 'prerender_component_publish_files_testdata'); +const root = 'packages/rules_prerender/prerender_component_publish_files_testdata'; describe('prerender_component_publish_files()', () => { it('includes exactly the expected files', async () => { diff --git a/packages/script_entry_generator/BUILD.bazel b/packages/script_entry_generator/BUILD.bazel index 6a148998..bcf364c1 100644 --- a/packages/script_entry_generator/BUILD.bazel +++ b/packages/script_entry_generator/BUILD.bazel @@ -34,7 +34,6 @@ ts_project( "//common/models:prerender_metadata_mock", "//common/testing:binary", "//common/testing:temp_dir", - "@npm//@bazel/runfiles", "@npm//@types/jasmine", "@npm//@types/node", ], diff --git a/packages/script_entry_generator/script_entry_generator_test.ts b/packages/script_entry_generator/script_entry_generator_test.ts index 4da9d142..84951899 100644 --- a/packages/script_entry_generator/script_entry_generator_test.ts +++ b/packages/script_entry_generator/script_entry_generator_test.ts @@ -1,11 +1,9 @@ import { promises as fs } from 'fs'; -import { runfiles } from '@bazel/runfiles'; import { mockPrerenderMetadata, mockScriptMetadata } from '../../common/models/prerender_metadata_mock'; import { execBinary, ProcessResult } from '../../common/testing/binary'; import { useTempDir } from '../../common/testing/temp_dir'; -const entryGenerator = - runfiles.resolvePackageRelative('script_entry_generator.sh'); +const entryGenerator = 'packages/script_entry_generator/script_entry_generator.sh'; /** Invokes the entry generator binary. */ async function run({ metadata, output }: { metadata: string, output: string }): diff --git a/tools/BUILD.bazel b/tools/BUILD.bazel index 75e607e2..e177e85c 100644 --- a/tools/BUILD.bazel +++ b/tools/BUILD.bazel @@ -1,7 +1,5 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -exports_files(["jasmine.json"], visibility = ["//visibility:public"]) - bzl_library( name = "jasmine", srcs = ["jasmine.bzl"], diff --git a/tools/jasmine.json b/tools/jasmine.json deleted file mode 100644 index 1e10fb11..00000000 --- a/tools/jasmine.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "failSpecWithNoExpectations": true -} diff --git a/tools/jasmine_node_test.bzl b/tools/jasmine_node_test.bzl index bc9b3bb1..c1bf7113 100644 --- a/tools/jasmine_node_test.bzl +++ b/tools/jasmine_node_test.bzl @@ -1,21 +1,59 @@ -"""Wraps `@bazel/jasmine` tooling for the respository.""" +"""Defines `jasmine_node_test()`.""" +load("@aspect_bazel_lib//lib:copy_file.bzl", "copy_file") load("@npm//@bazel/jasmine:index.bzl", _jasmine_node_test = "jasmine_node_test") +load("@npm_rules_js//:jasmine/package_json.bzl", jasmine_bin = "bin") -def jasmine_node_test(**kwargs): +def jasmine_node_test(name, deps, data = [], **kwargs): """Wrapper for the `jasmine_node_test()` rule. Args: - **kwargs: Arguments to pass through to the real `jasmine_node_test()`. + name: Name of this target. + data: https://docs.bazel.build/versions/main/be/common-definitions.html#common-attributes + deps: Targets whose `DefaultInfo` files are executed as Jasmine tests. + **kwargs: Arguments to pass through to the real `jasmine_node_test()`. """ - _jasmine_node_test( - config_file = kwargs.pop("config_file", None) or "//tools:jasmine.json", - templated_args = kwargs.pop("templated_args", []) + [ - # Patch module resolution until I understand how to address: - # https://github.com/bazelbuild/rules_nodejs/issues/2388 - "--bazel_patch_module_resolver", - # Fail the test on unhandled rejection. - "--node_options=--unhandled-rejections=strict", + # Generate a config file for the test. + config_file = "%s_config.json" % name + _jasmine_config( + name = config_file, + testonly = True, + deps = deps, + ) + + # Generate the actual test from the `@aspect_rules_js` generated binary for the `jasmine` + # NPM package. + jasmine_bin.jasmine_test( + name = name, + # Note: These args are not applied to `jasmine_web_test_suite()`. + # Any changes need to be manually applied to that macro. + args = ["--config=$(rootpath :%s)" % config_file], + data = data + deps + [ + ":%s" % config_file, ], - **kwargs + testonly = True, + **kwargs, ) + +def _jasmine_config_impl(ctx): + config = ctx.actions.declare_file(ctx.attr.name) + + ctx.actions.write(config, json.encode_indent({ + "spec_dir": "", + "spec_files": [file.short_path for file in ctx.files.deps + if file.extension == "js"], + "failSpecWithNoExpectations": True, + })) + + return DefaultInfo(files = depset([config])) + +_jasmine_config = rule( + implementation = _jasmine_config_impl, + attrs = { + "deps": attr.label_list(mandatory = True), + }, + doc = """ + Generates a JSON file with the same name as the rule which executes direct + dependencies as tests. + """, +) diff --git a/tools/jasmine_web_test_suite.bzl b/tools/jasmine_web_test_suite.bzl index c5f00079..449db9c2 100644 --- a/tools/jasmine_web_test_suite.bzl +++ b/tools/jasmine_web_test_suite.bzl @@ -97,6 +97,7 @@ def jasmine_web_test_suite( **kwargs: Arguments for the `jasmine_node_test()` target. """ wrapped_test_name = "%s_wrapped_test" % name + wrapped_test_config = "%s_config.json" % wrapped_test_name # The wrapped `jasmine_node_test()` being executed. jasmine_node_test( @@ -118,6 +119,10 @@ def jasmine_web_test_suite( browsers = browsers, browser_overrides = browser_overrides, config = config, + # `web_test_suite()` uses a different action from the wrapped test, so args + # get dropped and need to be specified here. + args = ["--config=$(rootpath :%s)" % wrapped_test_config], + data = [":%s" % wrapped_test_config], flaky = flaky, local = local, shard_count = shard_count,