我有一个简单的可组合项useRoles,需要测试
import { computed } from "vue";
import { useStore } from "./store";
export default function useRoles() {
const store = useStore();
const isLearner = computed(() => store.state.profile.currentRole === "learner");
return {
isLearner
};
}
Run Code Online (Sandbox Code Playgroud)
我的测试方法如下
import { afterEach, expect } from "vitest";
import useRoles from "./useRoles";
describe("useRoles", () => {
afterEach(() => {
vi.clearAllMocks();
vi.resetAllMocks();
});
it("should verify values when is:Learner", () => { // works
vi.mock("./store", () => ({
useStore: () => ({
state: {
profile: …Run Code Online (Sandbox Code Playgroud) 我在PhpStorm中使用Yii2框架。
当我使用$this->render函数在具有一些变量的主文件中包含另一个代码片段时,我的问题出现在视图中。
代码本身可以完美运行,我只需要突出显示即可。
这是我的代码:
<?php
echo $this->render('commentsBlock', [
"comments" => $comments,
'deleteURL' => $deleteURL,
'editURL' => $editURL,
]);
?>
Run Code Online (Sandbox Code Playgroud)
上面的代码呈现了commentsBlock.php,该目标文件的内容如下:
如您所见,PhpStorm认为变量在定义时未声明。
我知道我需要添加一些注释,以告知IDE确实存在var,但是到目前为止,我尝试过的工作没有奏效。
我这样做:
但这不是重点。
关于如何正确编写此注释部分以欺骗IDE以突出显示我的变量的任何想法?