Home / File/ context.test.js — astro Source File

context.test.js — astro Source File

Architecture documentation for context.test.js, a javascript file in the astro codebase. 4 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  6d9ca61e_cd53_17b6_7d61_250d2cd75e73["context.test.js"]
  5a8ea2e9_371c_85ac_e291_f7588596f7b6["../dist/index.js"]
  6d9ca61e_cd53_17b6_7d61_250d2cd75e73 --> 5a8ea2e9_371c_85ac_e291_f7588596f7b6
  0e588d0c_5409_f008_bf3b_3762dd6c1c5a["strict"]
  6d9ca61e_cd53_17b6_7d61_250d2cd75e73 --> 0e588d0c_5409_f008_bf3b_3762dd6c1c5a
  4a95fcbc_1e80_e316_c274_6d1e9ed84ecf["node:os"]
  6d9ca61e_cd53_17b6_7d61_250d2cd75e73 --> 4a95fcbc_1e80_e316_c274_6d1e9ed84ecf
  fa887d9d_247c_d770_d661_490745669024["node:test"]
  6d9ca61e_cd53_17b6_7d61_250d2cd75e73 --> fa887d9d_247c_d770_d661_490745669024
  style 6d9ca61e_cd53_17b6_7d61_250d2cd75e73 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import assert from 'node:assert/strict';
import os from 'node:os';
import { describe, it } from 'node:test';
import { getContext } from '../dist/index.js';

describe('context', () => {
	it('no arguments', async () => {
		const ctx = await getContext([]);
		assert.ok(!ctx.projectName);
		assert.ok(!ctx.template);
		assert.deepEqual(ctx.skipHouston, os.platform() === 'win32');
		assert.ok(!ctx.dryRun);
	});

	it('project name', async () => {
		const ctx = await getContext(['foobar']);
		assert.deepEqual(ctx.projectName, 'foobar');
	});

	it('template', async () => {
		const ctx = await getContext(['--template', 'minimal']);
		assert.deepEqual(ctx.template, 'minimal');
	});

	it('skip houston (explicit)', async () => {
		const ctx = await getContext(['--skip-houston']);
		assert.deepEqual(ctx.skipHouston, true);
	});

	it('skip houston (yes)', async () => {
		const ctx = await getContext(['-y']);
		assert.deepEqual(ctx.skipHouston, true);
	});

	it('skip houston (no)', async () => {
		const ctx = await getContext(['-n']);
		assert.deepEqual(ctx.skipHouston, true);
	});

	it('skip houston (install)', async () => {
		const ctx = await getContext(['--install']);
		assert.deepEqual(ctx.skipHouston, true);
	});

	it('dry run', async () => {
		const ctx = await getContext(['--dry-run']);
		assert.deepEqual(ctx.dryRun, true);
	});

	it('install', async () => {
		const ctx = await getContext(['--install']);
		assert.deepEqual(ctx.install, true);
	});

	it('add', async () => {
		const ctx = await getContext(['--add', 'node']);
		assert.deepEqual(ctx.add, ['node']);
	});

	it('no install', async () => {
		const ctx = await getContext(['--no-install']);
		assert.deepEqual(ctx.install, false);
	});

	it('git', async () => {
		const ctx = await getContext(['--git']);
		assert.deepEqual(ctx.git, true);
	});

	it('no git', async () => {
		const ctx = await getContext(['--no-git']);
		assert.deepEqual(ctx.git, false);
	});

	it('--add with --no-install conflicts', async () => {
		const exitCode = await new Promise((resolve) => {
			const originalExit = process.exit;
			process.exit = (code) => {
				process.exit = originalExit;
				resolve(code);
			};
			getContext(['--add', 'cloudflare', '--no-install']);
		});
		assert.equal(exitCode, 1);
	});
});

Domain

Dependencies

  • ../dist/index.js
  • node:os
  • node:test
  • strict

Frequently Asked Questions

What does context.test.js do?
context.test.js is a source file in the astro codebase, written in javascript. It belongs to the FrameworkCore domain.
What does context.test.js depend on?
context.test.js imports 4 module(s): ../dist/index.js, node:os, node:test, strict.
Where is context.test.js in the architecture?
context.test.js is located at packages/create-astro/test/context.test.js (domain: FrameworkCore, directory: packages/create-astro/test).

Analyze Your Own Codebase

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

Try Supermodel Free