Home / File/ astro-mode.test.js — astro Source File

astro-mode.test.js — astro Source File

Architecture documentation for astro-mode.test.js, a javascript file in the astro codebase. 6 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  9808fe19_c6fd_f76e_3a0d_47eb5c23c58e["astro-mode.test.js"]
  0a624eac_945e_c9e8_c9de_3feb9de2dd15["test-utils.js"]
  9808fe19_c6fd_f76e_3a0d_47eb5c23c58e --> 0a624eac_945e_c9e8_c9de_3feb9de2dd15
  dd4f09ce_3fd7_8295_f616_8876cda4555c["loadFixture"]
  9808fe19_c6fd_f76e_3a0d_47eb5c23c58e --> dd4f09ce_3fd7_8295_f616_8876cda4555c
  e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"]
  9808fe19_c6fd_f76e_3a0d_47eb5c23c58e --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607
  e16a223b_37f3_6b25_1ee1_2b7bcb9d9415["node:fs"]
  9808fe19_c6fd_f76e_3a0d_47eb5c23c58e --> e16a223b_37f3_6b25_1ee1_2b7bcb9d9415
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  9808fe19_c6fd_f76e_3a0d_47eb5c23c58e --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  deb87372_5629_35f8_9a54_e755a08f776a["cheerio"]
  9808fe19_c6fd_f76e_3a0d_47eb5c23c58e --> deb87372_5629_35f8_9a54_e755a08f776a
  style 9808fe19_c6fd_f76e_3a0d_47eb5c23c58e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import assert from 'node:assert/strict';
import { existsSync, promises as fs } from 'node:fs';
import { after, afterEach, before, describe, it } from 'node:test';
import * as cheerio from 'cheerio';
import { loadFixture } from './test-utils.js';

describe('--mode', () => {
	/** @type {import('./test-utils.js').Fixture} */
	let fixture;
	let devDataStoreFile;
	let prodDataStoreFile;

	async function deleteDataStoreFiles() {
		await fs.unlink(devDataStoreFile).catch(() => {});
		await fs.unlink(prodDataStoreFile).catch(() => {});
	}

	before(async () => {
		fixture = await loadFixture({
			root: './fixtures/astro-mode/',
		});
		devDataStoreFile = new URL('./.astro/data-store.json', fixture.config.root);
		prodDataStoreFile = new URL('./node_modules/.astro/data-store.json', fixture.config.root);
	});

	afterEach(() => {
		// Reset so it doesn't interfere with other tests as builds below
		// will interact with env variables loaded from .env files
		delete process.env.NODE_ENV;
		// `astro:env` writes to `process.env` currently which should be avoided,
		// otherwise consecutive builds can't get the latest `.env` values. Workaround
		// here for now be resetting it.
		delete process.env.TITLE;
	});

	describe('build', () => {
		before(async () => {
			await deleteDataStoreFiles();
			await fixture.build();
		});

		it('works', async () => {
			const html = await fixture.readFile('/index.html');
			const $ = cheerio.load(html);
			assert.equal($('#env-mode').text(), 'production');
			assert.equal($('#env-dev').text(), 'false');
			assert.equal($('#env-prod').text(), 'true');
			assert.equal($('#env-title').text(), 'production');
			assert.equal($('#env-astro-title').text(), 'production');
		});

		it('writes data store file in the correct location', async () => {
			assert.ok(existsSync(prodDataStoreFile));
		});
	});

	describe('build --mode testing --devOutput', () => {
		before(async () => {
			await deleteDataStoreFiles();
			await fixture.build({ mode: 'testing' }, { devOutput: true });
// ... (96 more lines)

Dependencies

Frequently Asked Questions

What does astro-mode.test.js do?
astro-mode.test.js is a source file in the astro codebase, written in javascript. It belongs to the IntegrationAdapters domain.
What does astro-mode.test.js depend on?
astro-mode.test.js imports 6 module(s): cheerio, loadFixture, node:fs, node:test, strict, test-utils.js.
Where is astro-mode.test.js in the architecture?
astro-mode.test.js is located at packages/astro/test/astro-mode.test.js (domain: IntegrationAdapters, directory: packages/astro/test).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free