-
-
Notifications
You must be signed in to change notification settings - Fork 826
Closed
Labels
S-Needs triageStatus: this issue needs to be triagedStatus: this issue needs to be triaged
Description
Environment information
CLI:
Version: 1.9.4
Color support: true
Platform:
CPU Architecture: x86_64
OS: macos
Environment:
BIOME_LOG_PATH: unset
BIOME_LOG_PREFIX_NAME: unset
BIOME_CONFIG_PATH: unset
NO_COLOR: unset
TERM: "xterm-256color"
JS_RUNTIME_VERSION: "v22.14.0"
JS_RUNTIME_NAME: "node"
NODE_PACKAGE_MANAGER: "pnpm/10.6.1"
Biome Configuration:
Status: Loaded successfully
Formatter disabled: false
Linter disabled: false
Organize imports disabled: false
VCS disabled: false
Formatter:
Format with errors: false
Indent style: Space
Indent width: 2
Line ending: Lf
Line width: 100
Attribute position: Auto
Bracket spacing: BracketSpacing(true)
Ignore: []
Include: []
JavaScript Formatter:
Enabled: false
JSX quote style: Double
Quote properties: AsNeeded
Trailing commas: None
Semicolons: Always
Arrow parentheses: AsNeeded
Bracket spacing: unset
Bracket same line: false
Quote style: Double
Indent style: unset
Indent width: unset
Line ending: unset
Line width: unset
Attribute position: unset
JSON Formatter:
Enabled: true
Indent style: unset
Indent width: unset
Line ending: unset
Line width: unset
Trailing Commas: unset
CSS Formatter:
Enabled: true
Indent style: unset
Indent width: unset
Line ending: unset
Line width: unset
Quote style: Double
GraphQL Formatter:
Enabled: false
Indent style: unset
Indent width: unset
Line ending: unset
Line width: unset
Bracket spacing: unset
Quote style: unset
Workspace:
Open Documents: 0
What happened?
- Write the following code in a TypeScript file:
./test/release/set-last-release.test.ts
import type { Context } from "../../src/cli/cli.types.js";
import { afterEach, assert, beforeEach, describe, expect, it, vi } from "vitest";
import { getAllTags } from "../../src/git/get-all-tags.js";
import { runCommand } from "../../src/git/run-command.js";
import { setLastRelease } from "../../src/release/set-last-release.js";
describe("set last release", () => {
const mockedRepositoryUrl = "https://github.com/user-id/repo-name";
const mockedConfig = {
branches: ["alpha", "beta", "main", "master", "next"],
releaseType: {
alpha: {
channel: "alpha",
prerelease: true
},
beta: {
channel: "beta",
prerelease: true
},
main: {
channel: "default"
},
master: {
channel: "default"
},
next: {
channel: "next",
prerelease: true
}
},
debug: false,
dryRun: false,
repositoryUrl: mockedRepositoryUrl,
remoteName: "origin"
};
const mockedContext = {
cwd: "/fake/path",
env: {},
branch: "main",
config: mockedConfig,
logger: {
logDebug: vi.fn(),
logInfo: vi.fn(),
logError: vi.fn(),
logWarn: vi.fn(),
logSuccess: vi.fn()
}
} as Context;
const mockedContextWithInelegibleBranch = { ...mockedContext, branch: "unmatched-branch" };
const mockedTags = [
"v2.0.0",
"v2.0.0-rc.2",
"v2.0.0-rc.1",
"v2.0.0-beta.3",
"v2.0.0-beta.2",
"v2.0.0-beta.1",
"v2.0.0-alpha.4",
"v2.0.0-alpha.3",
"v2.0.0-alpha.2",
"v2.0.0-alpha.1",
"v1.1.0",
"v1.0.1",
"v1.0.0",
"v0.2.0",
"v0.1.0"
];
beforeEach(() => {
vi.mock("../../src/git/get-all-tags.js", () => ({ getAllTags: vi.fn() }));
});
afterEach(() => {
vi.clearAllMocks();
});
// it("should log an error message when an error is thrown", () => {
// const mockedCommandResult = {
// status: 1,
// stdout: "",
// stderr: "Error"
// };
// vi.mocked(runCommand).mockReturnValue(mockedCommandResult);
// expect(() => getAllTags(mockedContext)).toThrowError();
// expect(mockedContext.logger?.logError).toHaveBeenCalled();
// });
it("should return `false` if the package cannot publish from the branch", () => {
expect(setLastRelease(mockedContextWithInelegibleBranch)).toBe(false);
});
it("should add the last release to the context according to the branch", () => {
// const mockedCommandResult = {
// status: 0,
// stdout: mockedTags.join("\n"),
// stderr: ""
// };
setLastRelease(mockedContext);
assert.deepEqual(getAllTags(mockedContext), mockedTags);
});
it("should return an empty array if no tags are found", () => {
const mockedCommandResult = {
status: 0,
stdout: "",
stderr: ""
};
vi.mocked(runCommand).mockReturnValue(mockedCommandResult);
assert.deepEqual(getAllTags(mockedContext), []);
});
});- Run
pnpm exec biome check . - The output reports an error:
./test/release/set-last-release.test.ts organizeImports ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Import statements could be sorted:
1 1 │ import type { Context } from "../../src/cli/cli.types.js";
2 2 │
3 │ - import·{·afterEach,·assert,·beforeEach,·describe,·expect,·it,·vi·}·from·"vitest";
3 │ + import·{·assert,·afterEach,·beforeEach,·describe,·expect,·it,·vi·}·from·"vitest";
4 4 │
5 5 │ import { getAllTags } from "../../src/git/get-all-tags.js";
Expected result
It should not throw an error.
Code of Conduct
- I agree to follow Biome's Code of Conduct
Metadata
Metadata
Assignees
Labels
S-Needs triageStatus: this issue needs to be triagedStatus: this issue needs to be triaged