@arcgis/node-toolkit 6.0.0-next.26 → 6.0.0-next.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ /** @internal */
2
+ export declare const testTimezone = "UTC";
@@ -0,0 +1,4 @@
1
+ const testTimezone = "UTC";
2
+ export {
3
+ testTimezone
4
+ };
@@ -5,6 +5,7 @@ export type VitePresetOptions = DependencyManagementOptions;
5
5
  /**
6
6
  * Vite preset for all our support packages:
7
7
  * - externalizes all non-dev-dependencies
8
+ * - sets the default timezone for tests
8
9
  *
9
10
  * @public
10
11
  * @param options
@@ -1,4 +1,5 @@
1
1
  import { externalizeDependencies } from "./externalizeDependenciesPlugin.js";
2
+ import { configureTestTimezone } from "./testTimezone.js";
2
3
  const hashlessOutputNames = {
3
4
  assetFileNames: "assets/[name][extname]",
4
5
  chunkFileNames: "chunks/[name].js"
@@ -13,6 +14,7 @@ function vitePresetPlugin({ externalize, bundleIn, isApplication } = { externali
13
14
  const output = rollupOptions?.output;
14
15
  const hashlessOutput = Array.isArray(output) ? output.map((entry) => ({ ...hashlessOutputNames, ...entry })) : { ...hashlessOutputNames, ...output };
15
16
  return {
17
+ ...configureTestTimezone(config, env),
16
18
  build: {
17
19
  // REFACTOR: get this from tsconfig
18
20
  // It's a best practice to let the final bundler down-level as needed.
@@ -0,0 +1,8 @@
1
+ import type { ConfigEnv, Plugin, UserConfig } from "vite";
2
+ export declare function configureTestTimezone(config: UserConfig, env: ConfigEnv): UserConfig | undefined;
3
+ /**
4
+ * Apply the repository's timezone policy to Vitest processes and Playwright contexts.
5
+ *
6
+ * @public
7
+ */
8
+ export declare function testTimezonePlugin(): Plugin;
@@ -0,0 +1,35 @@
1
+ import { testTimezone } from "../testTimezone.js";
2
+ function configureTestTimezone(config, env) {
3
+ if (env.command !== "serve" || process.env.VITEST !== "true") {
4
+ return void 0;
5
+ }
6
+ const timezone = config.test?.env?.TZ ?? testTimezone;
7
+ process.env.TZ = timezone;
8
+ const browser = config.test?.browser;
9
+ configurePlaywrightTimezone(browser?.provider, timezone);
10
+ for (const instance of browser?.instances ?? []) {
11
+ configurePlaywrightTimezone(instance.provider, timezone);
12
+ }
13
+ return { test: { env: { TZ: timezone } } };
14
+ }
15
+ function testTimezonePlugin() {
16
+ return {
17
+ name: "@arcgis/node-toolkit:test-timezone",
18
+ enforce: "post",
19
+ config: configureTestTimezone
20
+ };
21
+ }
22
+ function configurePlaywrightTimezone(provider, timezone) {
23
+ if (!isPlaywrightProvider(provider)) {
24
+ return;
25
+ }
26
+ provider.options.contextOptions ??= {};
27
+ provider.options.contextOptions.timezoneId ??= timezone;
28
+ }
29
+ function isPlaywrightProvider(provider) {
30
+ return provider?.name === "playwright";
31
+ }
32
+ export {
33
+ configureTestTimezone,
34
+ testTimezonePlugin
35
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/node-toolkit",
3
- "version": "6.0.0-next.26",
3
+ "version": "6.0.0-next.28",
4
4
  "description": "Collection of common internal build-time patterns and utilities for ArcGIS Maps SDK for JavaScript components.",
5
5
  "homepage": "https://developers.arcgis.com/javascript/latest/",
6
6
  "type": "module",
@@ -13,7 +13,9 @@
13
13
  "./glob": "./dist/glob.js",
14
14
  "./path": "./dist/path.js",
15
15
  "./packageJson": "./dist/packageJson.js",
16
+ "./testTimezone": "./dist/testTimezone.js",
16
17
  "./vite/presetPlugin": "./dist/vite/presetPlugin.js",
18
+ "./vite/testTimezone": "./dist/vite/testTimezone.js",
17
19
  "./vite/externalizeDependenciesPlugin": "./dist/vite/externalizeDependenciesPlugin.js",
18
20
  "./vite/installPlaywright": "./dist/vite/installPlaywright.js",
19
21
  "./vite/simpleTypesEmit": "./dist/vite/simpleTypesEmit.js",