– It doesn’t rival the Islamic State in Iraq and the Levant or abortion as an issue in the presidential race, but China might be the most complex challenge the winner will have to deal with.

The country, which has the world’s second-biggest economy and second-highest military spending, is a frenemy of the first order. It finances America’s federal budget deficit by buying Treasury bonds, and it sends more students to the U.S. than any other nation. It’s a natural ally on some issues (Islamic terrorism) but an implacable foe on others (freedom of navigation in the South China Sea).

President Obama will bequeath his successor a string of partial successes. China, the biggest greenhouse gas polluter, agreed with the U.S. to curb emissions, albeit not as fast as the administration would like. It allowed its currency to gain in value, making its exports less competitive — although lately the yuan has fallen again. China didn’t retaliate after the U.S. Navy cruised by contested islands in the South China Sea in October, but the country’s Ministry of National Defense didn’t hesitate to accuse Washington of a “serious military provocation” on Dec. 19, days after a pair of B-52 bombers flew over Chinese-built artificial islands in the same area. The share of Americans who regard China unfavorably went down slightly in 2015, after ticking up for several years. But China is determined to assert itself — and challenge U.S. supremacy — on many fronts over the next four years and beyond. “Any candidate has to treat them with nuance, or should,” says Ted Truman, a nonresident senior fellow at the Peterson Institute for International Economics.

So far, nuance has been missing from the campaign. Donald Trump, the leading Republican in the polls, speaks of China primarily as a cheater. It’s not a new line of attack — 2012 Republican nominee Mitt Romney, whose Bain Capital backed companies that helped outsource jobs to China, described the Chinese in the same terms.

The leading Democrat, Hillary Clinton, sounds nearly as hawkish on the subject of Beijing. As Obama’s secretary of state from 2009 to 2013, she introduced the “pivot to Asia” policy, designed in part to prevent Chinese hegemony in the region. At a New Hampshire event last July, shortly after it was revealed that China was behind a massive electronic intrusion into U.S. Department of State personnel records, she accused the country of “trying to hack into everything that doesn’t move in America.”

China is a litmus test for how the presidential candidates would govern on a broad range of issues. Are they isolationists or interventionists? Do they see foreign policy as a job for the White House or for Congress? How would they strike a balance between concern for human rights and the economy? Which constituency do they most aim to please — business, labor, religious groups, environmentalists, defense hawks?

If history is a guide, the candidate who wins in November is likely to be more moderate in office than he or she was on the campaign trail.

“China-bashing is part of American campaign politics, and we get that,” said Tao Wenzhao, senior researcher at the Institute of American Studies, part of the Beijing-based Chinese Academy of Social Sciences.

President Richard Nixon, a fierce anti-communist, broke the ice with Chairman Mao Zedong by traveling to Beijing in 1972. Presidents Ronald Reagan, Bill Clinton, and George W. Bush also talked tougher on China during their campaigns than they acted once in office.