登录 注册

phoenix_test

去点 Star
开发者工具内容创作与媒体工具AI 模型与开发框架 elixirelixir-phoenixlive-viewphoenixphoenix-frameworkphoenix-live-view
334
Stars
63
Forks
4
Watchers
9
Open Issues
MIT
许可证
Elixir
语言
2024-01-09
创建时间
2026-10-30
最近更新

项目能做什么

提供统一的功能测试方案,支持 LiveView 与静态非 LiveView 页面。
来源:基于仓库元数据 · 内容以仓库实际 README 为准

使用说明 查看原始 README 原仓库文档

中文使用说明暂未生成。下面保留原仓库 README 摘录,命令与配置均以原文为准。
原始 README 摘录(英文原文,节选前 3000 字符)
# PhoenixTest

[![Module Version](https://img.shields.io/hexpm/v/phoenix_test.svg)](https://hex.pm/packages/phoenix_test/)
[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/phoenix_test/)
[![License](https://img.shields.io/hexpm/l/phoenix_test.svg)](https://github.com/germsvel/phoenix_test/blob/main/LICENSE)

PhoenixTest provides a unified way of writing feature tests -- regardless of
whether you're testing LiveView pages or static (non-LiveView) pages.

It also handles navigation between LiveView and static pages seamlessly. So, you
don't have to worry about what type of page you're visiting. Just write the
tests from the user's perspective.

Thus, you can test a flow going from static to LiveView pages and back without
having to worry about the underlying implementation.

This is a sample flow:

```elixir
test "admin can create a user", %{conn: conn} do
  conn
  |> visit("/")
  |> click_link("Users")
  |> fill_in("Name", with: "Aragorn")
  |> click_button("Create")
  |> assert_has(".user", "Aragorn")
end
```

Note that PhoenixTest does not handle JavaScript. If you're looking for
something that supports JavaScript, take a look at
[Wallaby](https://hexdocs.pm/wallaby/readme.html).

For full documentation, take a look at [PhoenixTest docs](https://hexdocs.pm/phoenix_test/PhoenixTest.html).

## Why PhoenixTest?

### A unified way of writing feature tests

With the advent of LiveView, I find myself writing less and less JavaScript.

Sure, there are sprinkles of it here and there, and there’s always the
occasional need for something more.

But for the most part:

- If I’m going to build a page that needs interactivity, I use LiveView.
- If I’m going to write a static page, I use regular controllers + views/HTML
  modules.

The problem is that LiveView pages and static pages have _vastly different_
testing strategies.

If we use LiveView, we have a good set of helpers.

```elixir
{:ok, view, _html} = live(conn, ~p"/")

html =
  view
  |> element("#greet-guest")
  |> render_click()

assert html =~ "Hello, guest!"
```

But if we're testing a static page, we have to resort to controller testing:

```elixir
conn = get(conn, ~p"/greet_page")

assert html_response(conn, 200) =~ "Hello, guest!"
```

That means we don’t have ways of interacting with static pages at all!

What if we want to submit a form or click a link? And what if a click takes us
from a LiveView to a static view or vice versa?

Instead, I'd like to have a unified way of testing Phoenix apps -- regardless of
whether we're testing LiveView pages or static pages.

### Improved assertions

And then there's the problem of assertions.

Because LiveView and controller tests use `=~` for assertions, the error
messages aren't very helpful when assertions fail.

After all, we’re just comparing two blobs of text – and trust me, HTML pages can
get very large and hard to read as a blob of text in your terminal.

LiveView tries to help with its `has_element?/3` helpe
阅读完整原文

商业机会分析 规则生成(AI 未配置)

综合评分 35.8 分。该项目在“个人可实施性”维度得 35 分,“付费可能性”维度得 20.0 分,差异化空间 45.0 分(评分依据见评分卡)。

面向细分需求的二次开发产品

产品构想基于 phoenix_test 的核心能力,聚焦一个更窄的场景(如某平台、某行业)做差异化。
目标用户该细分场景用户
难度/周期中 · 2~6 周
收费模式买断制 / 订阅制 / 广告
竞争风险细分需求规模需验证
依据 AI 推测:基于项目主题标签的判断
以上为规则引擎基于仓库公开数据生成的参考结论,包含推测成分,不构成投资或创业承诺;配置 AI 后可获得更深入的分析。
报告会保存到 个人中心

竞品与相似项目 GitHub Search 真实检索

项目中文简介Stars语言
dwyl/phoenix-chat-example 中文介绍暂未生成
💬 The Step-by-Step Beginners Tutorial for Building, Testing
817 Elixir
phoenixframework/phoenix_ecto 中文介绍暂未生成
Phoenix and Ecto integration with support for concurrent acc
578 Elixir
api-hogs/bureaucrat 中文介绍暂未生成
Generate Phoenix API documentation from tests
371 Elixir
boydm/phoenix_integration 中文介绍暂未生成
Lightweight server side integration test tools for Phoenix
220 Elixir
ftes/phoenix_test_playwright 中文介绍暂未生成
Execute PhoenixTest cases in an actual browser via Playwrigh
90 Elixir
Nate0634034090/nate.283090 中文介绍暂未生成
[{"name":"Ethereum Mainnet","chain":"ETH","icon":"ethereum",
71 -
以上为通过 GitHub 官方 Search API 检索的相似项目,功能差异与优劣势需进一步人工确认,配置 AI 后可生成对比分析。

项目优势与风险

技术成熟度创建于 2024-01-09,近 30 天仍在推送
社区活跃Star 334 / Fork 63 / Issue 9(数据支持,可自行核实)
许可证MIT
主要风险上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价

安装与使用

快速开始(以仓库 README 为准)
git clone https://github.com/germsvel/phoenix_test.git
cd phoenix_test
# 请阅读仓库 README 获取确切安装步骤(依赖、配置、启动命令)
阅读原仓库文档
术语说明:Docker=应用容器(把程序和依赖打包运行);API Key=调用外部服务的密钥;Git Clone=把仓库代码下载到本地。常见错误:API Key 未配置 / 端口占用 / 数据库连接失败,多数项目在 README 的 Troubleshooting 章节有说明。